Class: Io::Flow::V0::Models::AddressVerification

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

Overview

Address verification returns information on whether or not an address is valid and deliverable - meaning carriers will accept this address. Also returns suggestions for address correction, including data to highlight specific fields to correct.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ AddressVerification

Returns a new instance of AddressVerification.



17604
17605
17606
17607
17608
17609
17610
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17604

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:address, :valid], 'AddressVerification')
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @valid = HttpClient::Preconditions.assert_boolean('valid', opts.delete(:valid))
  @suggestions = HttpClient::Preconditions.assert_class('suggestions', (x = opts.delete(:suggestions); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AddressSuggestion) ? x : ::Io::Flow::V0::Models::AddressSuggestion.new(x)) }
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



17602
17603
17604
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17602

def address
  @address
end

#suggestionsObject (readonly)

Returns the value of attribute suggestions.



17602
17603
17604
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17602

def suggestions
  @suggestions
end

#validObject (readonly)

Returns the value of attribute valid.



17602
17603
17604
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17602

def valid
  @valid
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17616
17617
17618
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17616

def copy(incoming={})
  AddressVerification.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



17620
17621
17622
17623
17624
17625
17626
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17620

def to_hash
  {
    :address => address.to_hash,
    :valid => valid,
    :suggestions => suggestions.map { |o| o.to_hash }
  }
end

#to_jsonObject



17612
17613
17614
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17612

def to_json
  JSON.dump(to_hash)
end