Class: Io::Flow::V0::Models::AddressSuggestion

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

Overview

A suggested address (usually providing more accurate information). This object contains both the suggested address as well as metadata on which fields are actually different

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ AddressSuggestion

Returns a new instance of AddressSuggestion.



13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13698

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:address, :streets, :city, :province, :postal, :country], 'AddressSuggestion')
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @streets = HttpClient::Preconditions.assert_boolean('streets', opts.delete(:streets))
  @city = HttpClient::Preconditions.assert_boolean('city', opts.delete(:city))
  @province = HttpClient::Preconditions.assert_boolean('province', opts.delete(:province))
  @postal = HttpClient::Preconditions.assert_boolean('postal', opts.delete(:postal))
  @country = HttpClient::Preconditions.assert_boolean('country', opts.delete(:country))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



13696
13697
13698
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13696

def address
  @address
end

#cityObject (readonly)

Returns the value of attribute city.



13696
13697
13698
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13696

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



13696
13697
13698
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13696

def country
  @country
end

#postalObject (readonly)

Returns the value of attribute postal.



13696
13697
13698
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13696

def postal
  @postal
end

#provinceObject (readonly)

Returns the value of attribute province.



13696
13697
13698
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13696

def province
  @province
end

#streetsObject (readonly)

Returns the value of attribute streets.



13696
13697
13698
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13696

def streets
  @streets
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13713
13714
13715
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13713

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

#to_hashObject



13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13717

def to_hash
  {
    :address => address.to_hash,
    :streets => streets,
    :city => city,
    :province => province,
    :postal => postal,
    :country => country
  }
end

#to_jsonObject



13709
13710
13711
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13709

def to_json
  JSON.dump(to_hash)
end