Class: Io::Flow::V0::Clients::Addresses
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Addresses
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get(incoming = {}) ⇒ Object
Geolocates the request based on the provided parameters, returning a list of potential matching addresses.
-
#initialize(client) ⇒ Addresses
constructor
A new instance of Addresses.
- #post_verifications(address) ⇒ Object
Constructor Details
#initialize(client) ⇒ Addresses
Returns a new instance of Addresses.
5369 5370 5371 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5369 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(incoming = {}) ⇒ Object
Geolocates the request based on the provided parameters, returning a list of potential matching addresses.
5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5375 def get(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :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)), :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)), :postal_prefix => (x = opts.delete(:postal_prefix); x.nil? ? nil : HttpClient::Preconditions.assert_class('postal_prefix', x, String)) }.delete_if { |k, v| v.nil? } r = @client.request("/addresses").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Address.new(x) } end |
#post_verifications(address) ⇒ Object
5387 5388 5389 5390 5391 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5387 def post_verifications(address) (x = address; x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)) r = @client.request("/addresses/verifications").with_json(address.to_json).post ::Io::Flow::V0::Models::AddressVerification.new(r) end |