Class: Geoip2::Client
- Inherits:
-
Object
- Object
- Geoip2::Client
- Includes:
- Api::City, Api::CityIspOrg, Api::Country, Api::Insights, Api::Omni
- Defined in:
- lib/geoip2/client.rb
Instance Method Summary collapse
-
#get(url, params = {}, faraday_options = {}) ⇒ Object
Does a GET request to the url with the params.
-
#in_parallel ⇒ Object
Does a parallel request to the api for all of the requests in the block.
-
#initialize(config) ⇒ Client
constructor
Creates a new instance of Geoip2::Client.
Methods included from Api::Omni
Methods included from Api::City
Methods included from Api::Country
Methods included from Api::Insights
Methods included from Api::CityIspOrg
Constructor Details
#initialize(config) ⇒ Client
Creates a new instance of Geoip2::Client
25 26 27 28 29 30 31 |
# File 'lib/geoip2/client.rb', line 25 def initialize(config) @base_url = "https://#{config[:host]}" @base_path = config[:base_path] @parallel_requests = config[:parallel_requests] @user = config[:user_id] @password = config[:license_key] end |
Instance Method Details
#get(url, params = {}, faraday_options = {}) ⇒ Object
Does a GET request to the url with the params
38 39 40 41 42 43 |
# File 'lib/geoip2/client.rb', line 38 def get(url, params = {}, = {}) params = params.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo} preform(@base_path + url, :get, params: params) do return connection().get(@base_path + url, params).body end end |
#in_parallel ⇒ Object
Does a parallel request to the api for all of the requests in the block
53 54 55 56 57 |
# File 'lib/geoip2/client.rb', line 53 def in_parallel connection.in_parallel do yield end end |