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.



9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9142

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

#address ⇒ Object (readonly)

Returns the value of attribute address.



9140
9141
9142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9140

def address
  @address
end

#city ⇒ Object (readonly)

Returns the value of attribute city.



9140
9141
9142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9140

def city
  @city
end

#country ⇒ Object (readonly)

Returns the value of attribute country.



9140
9141
9142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9140

def country
  @country
end

#postal ⇒ Object (readonly)

Returns the value of attribute postal.



9140
9141
9142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9140

def postal
  @postal
end

#province ⇒ Object (readonly)

Returns the value of attribute province.



9140
9141
9142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9140

def province
  @province
end

#streets ⇒ Object (readonly)

Returns the value of attribute streets.



9140
9141
9142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9140

def streets
  @streets
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



9157
9158
9159
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9157

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

#to_hash ⇒ Object



9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9161

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

#to_json ⇒ Object



9153
9154
9155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9153

def to_json
  JSON.dump(to_hash)
end