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.



11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11699

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.



11697
11698
11699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11697

def address
  @address
end

#cityObject (readonly)

Returns the value of attribute city.



11697
11698
11699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11697

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



11697
11698
11699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11697

def country
  @country
end

#postalObject (readonly)

Returns the value of attribute postal.



11697
11698
11699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11697

def postal
  @postal
end

#provinceObject (readonly)

Returns the value of attribute province.



11697
11698
11699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11697

def province
  @province
end

#streetsObject (readonly)

Returns the value of attribute streets.



11697
11698
11699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11697

def streets
  @streets
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11714
11715
11716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11714

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

#to_hashObject



11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11718

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

#to_jsonObject



11710
11711
11712
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11710

def to_json
  JSON.dump(to_hash)
end