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.



14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14241

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.



14239
14240
14241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14239

def address
  @address
end

#cityObject (readonly)

Returns the value of attribute city.



14239
14240
14241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14239

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



14239
14240
14241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14239

def country
  @country
end

#postalObject (readonly)

Returns the value of attribute postal.



14239
14240
14241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14239

def postal
  @postal
end

#provinceObject (readonly)

Returns the value of attribute province.



14239
14240
14241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14239

def province
  @province
end

#streetsObject (readonly)

Returns the value of attribute streets.



14239
14240
14241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14239

def streets
  @streets
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14256
14257
14258
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14256

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

#to_hashObject



14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14260

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

#to_jsonObject



14252
14253
14254
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14252

def to_json
  JSON.dump(to_hash)
end