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.



26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26009

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.



26007
26008
26009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26007

def address
  @address
end

#cityObject (readonly)

Returns the value of attribute city.



26007
26008
26009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26007

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



26007
26008
26009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26007

def country
  @country
end

#postalObject (readonly)

Returns the value of attribute postal.



26007
26008
26009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26007

def postal
  @postal
end

#provinceObject (readonly)

Returns the value of attribute province.



26007
26008
26009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26007

def province
  @province
end

#streetsObject (readonly)

Returns the value of attribute streets.



26007
26008
26009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26007

def streets
  @streets
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26024
26025
26026
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26024

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

#to_hashObject



26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26028

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

#to_jsonObject



26020
26021
26022
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26020

def to_json
  JSON.dump(to_hash)
end