Class: IpApi::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Fields
Defined in:
lib/ip_api/client.rb

Constant Summary

Constants included from Fields

Fields::FIELDS

Instance Method Summary collapse

Methods included from Fields

#field_to_numeric, #numeric_fields

Instance Method Details

#batch(addresses, options = {}) ⇒ Object



17
18
19
20
# File 'lib/ip_api/client.rb', line 17

def batch(addresses, options = {})
  query = build_query(**options) 
  self.class.post("/batch", { body: addresses.to_json, query: query })
end

#fetch(address, options = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/ip_api/client.rb', line 10

def fetch(address, options = {})
  return batch(address, options) if address.is_a?(Array)

  query = build_query(**options) 
  self.class.get("/json/#{address}", query: query)
end