Class: Io::Flow::V0::Clients::CountryDefaults
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::CountryDefaults
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(incoming = {}) ⇒ Object
- #get_by_country(country) ⇒ Object
-
#initialize(client) ⇒ CountryDefaults
constructor
A new instance of CountryDefaults.
Constructor Details
#initialize(client) ⇒ CountryDefaults
Returns a new instance of CountryDefaults.
3572 3573 3574 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3572 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(incoming = {}) ⇒ Object
3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3576 def get(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)), :address => (x = opts.delete(:address); x.nil? ? nil : HttpClient::Preconditions.assert_class('address', x, String)), :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)) }.delete_if { |k, v| v.nil? } r = @client.request("/geolocation/defaults").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::CountryDefaults.new(x) } end |
#get_by_country(country) ⇒ Object
3587 3588 3589 3590 3591 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3587 def get_by_country(country) HttpClient::Preconditions.assert_class('country', country, String) r = @client.request("/geolocation/defaults/#{CGI.escape(country)}").get ::Io::Flow::V0::Models::CountryDefaults.new(r) end |