Class: Io::Flow::V0::Models::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Defines structured fields for address to be used in user/form input. Either text or the structured input needs to be present.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Address

Returns a new instance of Address.



17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17520

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @text = (x = opts.delete(:text); x.nil? ? nil : HttpClient::Preconditions.assert_class('text', x, String))
  @streets = (x = opts.delete(:streets); x.nil? ? nil : HttpClient::Preconditions.assert_class('streets', x, Array).map { |v| HttpClient::Preconditions.assert_class('streets', v, String) })
  @street_number = (x = opts.delete(:street_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('street_number', x, String))
  @city = (x = opts.delete(:city); x.nil? ? nil : HttpClient::Preconditions.assert_class('city', x, String))
  @province = (x = opts.delete(:province); x.nil? ? nil : HttpClient::Preconditions.assert_class('province', x, String))
  @postal = (x = opts.delete(:postal); x.nil? ? nil : HttpClient::Preconditions.assert_class('postal', x, String))
  @country = (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String))
  @latitude = (x = opts.delete(:latitude); x.nil? ? nil : HttpClient::Preconditions.assert_class('latitude', x, String))
  @longitude = (x = opts.delete(:longitude); x.nil? ? nil : HttpClient::Preconditions.assert_class('longitude', x, String))
end

Instance Attribute Details

#cityObject (readonly)

Returns the value of attribute city.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def country
  @country
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def longitude
  @longitude
end

#postalObject (readonly)

Returns the value of attribute postal.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def postal
  @postal
end

#provinceObject (readonly)

Returns the value of attribute province.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def province
  @province
end

#street_numberObject (readonly)

Returns the value of attribute street_number.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def street_number
  @street_number
end

#streetsObject (readonly)

Returns the value of attribute streets.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def streets
  @streets
end

#textObject (readonly)

Returns the value of attribute text.



17518
17519
17520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17518

def text
  @text
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17537
17538
17539
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17537

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

#to_hashObject



17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17541

def to_hash
  {
    :text => text,
    :streets => streets.nil? ? nil : streets,
    :street_number => street_number,
    :city => city,
    :province => province,
    :postal => postal,
    :country => country,
    :latitude => latitude,
    :longitude => longitude
  }
end

#to_jsonObject



17533
17534
17535
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17533

def to_json
  JSON.dump(to_hash)
end