Class: RubyIpClient::IpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ip_client/ip_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ IpClient

Initializes the IP Lookup Client

Parameters:



12
13
14
15
16
# File 'lib/ruby_ip_client/ip_client.rb', line 12

def initialize(username, password)
  @username = username
  @password = password
  @url = "https://www.ip-lookups.com/api"
end

Instance Method Details

#get_balanceObject

Returns the remaining balance (EUR) in your account. Return example: RubyIpClient::IpClient.“success”:true,“results”:{“balance”:“5878“success”:true,“results”:{“balance”:“5878.24600”}



94
95
96
97
98
99
100
101
102
# File 'lib/ruby_ip_client/ip_client.rb', line 94

def get_balance

  send_request({
    :action => 'getBalance',
    :username => @username,
    :password => @password
  })

end

#set_async_callback_url(url) ⇒ Object

Sets the callback URL for asynchronous IP lookups. Read more about the concept of asynchronous IP lookups @ www.ip-lookups.com/en/asynchronous-ip-lookup-api Return example: href="www.your-server.com">www.your-server.com/path/file”}

Parameters:

  • url
    • callback url on your server



79
80
81
82
83
84
85
86
87
88
# File 'lib/ruby_ip_client/ip_client.rb', line 79

def set_async_callback_url(url)

  send_request({
    :action => 'setAsyncCallbackUrl',
    :url => url,
    :username => @username,
    :password => @password
  })

end

#submit_async_lookup(ips, engine = nil, storage = nil) ⇒ Object

Submits asynchronous IP Lookups containing up to 1,000 IPs per request. Results are sent back asynchronously to a callback URL on your server. Return example: href="{"id":"58cc4f7c4afc","ip":"85.10.208.227",RubyIpClient::IpClient."id":"d40499b8605c","ip":"85"id":"d40499b8605c","ip":"85.10"id":"d40499b8605c","ip":"85.10.208"id":"d40499b8605c","ip":"85.10.208.228",RubyIpClient::IpClient."id":"8bdc66d4ce52","ip":"85"id":"8bdc66d4ce52","ip":"85.208"id":"8bdc66d4ce52","ip":"85.208.221"id":"8bdc66d4ce52","ip":"85.208.221.221"">acceptedIps”:,“rejectedIps”:[],“acceptedIpCount”:3,“rejectedIpCount”:0,“totalCount”:3,“cost”:0.03,“storage”:“ASYNC-API-2017-02”,“engine”:“IV1”}}

Parameters:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby_ip_client/ip_client.rb', line 53

def submit_async_lookup(ips, engine = nil, storage = nil)

  params = {
      :action => 'submitAsyncLookup',
      :ips => ips_to_string(ips),
      :username => @username,
      :password => @password
  }

  unless engine.nil?
    params.merge!(engine: engine)
  end

  unless storage.nil?
    params.merge!(storage: storage)
  end

  send_request(params)

end

#submit_sync_lookup(ip, engine = nil, storage = nil) ⇒ Object

Submits a synchronous IP Lookup request. The IP is queried in real time and results presented in the response body. Return example: API”,“cost”:“0.01000”,“timeStamp”:“2017-02-18 18:27:50.267098+08”,“geolocation”:States”,“region”:“Arizona”,“countryCode”:“US”,“regionCode”:“AZ”,“city”:“Phoenix”,“zip”:“85054”,“latitude”:“33.67480”,“longitude”:“-111.95190”,“radius”:1000,“timeZone”:“America/Phoenix”,“averageIncome”:null,“populationDensity”:null,“dmaCode”:753,“network”:Technology Group, LLC”,“isp”:“Nobis Technology Group, LLC”,“ispOrganization”:“Nobis Technology Group, LLC”,“domain”:“ubiquity.io”,“registeredCountry”:“United States”,“registeredCountryCode”:“US”,“isRoutable”:true,“threatIntelligence”:“threatLevel”:“VERY_HIGH”,“threatIntelligenceScore”:“1.00000”,“genericBlacklistMatch”:true,“proxyBlacklistMatch”:true,“torBlacklistMatch”:false,“vpnBlacklistMatch”:true,“malwareBlacklistMatch”:false,“spywareBlacklistMatch”:false,“hijackBlacklistMatch”:false,“crawlerBlacklistMatch”:false,“botBlacklistMatch”:false,“spamBotBlacklistMatch”:false,“exploitBotBlacklistMatch”:false,“dshieldBlacklistMatch”:false}}

Parameters:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ruby_ip_client/ip_client.rb', line 25

def submit_sync_lookup(ip, engine = nil, storage = nil)

  params = {
    :action => 'submitSyncLookup',
    :ip => ip,
    :username => @username,
    :password => @password
  }

  unless engine.nil?
    params.merge!(engine: engine)
  end

  unless storage.nil?
    params.merge!(storage: storage)
  end

  send_request(params)

end