Class: Io::Flow::V0::Clients::Addresses

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Addresses

Returns a new instance of Addresses.



3362
3363
3364
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3362

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.



3368
3369
3370
3371
3372
3373
3374
3375
3376
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3368

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))
  }.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



3378
3379
3380
3381
3382
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3378

def post_verifications(address)
  HttpClient::Preconditions.assert_class('address', address, ::Io::Flow::V0::Models::Address)
  r = @client.request("/addresses/verifications").with_json(address.to_json).post
  ::Io::Flow::V0::Models::AddressVerification.new(r)
end