class Io::Flow::V0::Clients::Addresses

Public Class Methods

new(client) click to toggle source
# 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

Public Instance Methods

get(incoming={}) click to toggle source

Geolocates the request based on the provided parameters, returning a list of potential matching addresses.

# 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) click to toggle source
# 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