Class: Io::Flow::V0::Clients::CountryDefaults

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ CountryDefaults

Returns a new instance of CountryDefaults.



4987
4988
4989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4987

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#get(incoming = {}) ⇒ Object



4991
4992
4993
4994
4995
4996
4997
4998
4999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4991

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)),
    :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



5001
5002
5003
5004
5005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5001

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