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.



21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21899

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.



21897
21898
21899
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21897

def address
  @address
end

#cityObject (readonly)

Returns the value of attribute city.



21897
21898
21899
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21897

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



21897
21898
21899
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21897

def country
  @country
end

#postalObject (readonly)

Returns the value of attribute postal.



21897
21898
21899
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21897

def postal
  @postal
end

#provinceObject (readonly)

Returns the value of attribute province.



21897
21898
21899
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21897

def province
  @province
end

#streetsObject (readonly)

Returns the value of attribute streets.



21897
21898
21899
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21897

def streets
  @streets
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21914
21915
21916
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21914

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

#to_hashObject



21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21918

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

#to_jsonObject



21910
21911
21912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21910

def to_json
  JSON.dump(to_hash)
end