Class: Io::Flow::V0::Models::ShippingAddress

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingAddress

Returns a new instance of ShippingAddress.



37262
37263
37264
37265
37266
37267
37268
37269
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37262

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:contact, :location], 'ShippingAddress')
  @contact = (x = opts.delete(:contact); x.is_a?(::Io::Flow::V0::Models::Contact) ? x : ::Io::Flow::V0::Models::Contact.new(x))
  @location = (x = opts.delete(:location); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @center_key = (x = opts.delete(:center_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('center_key', x, String))
  @center_reference = (x = opts.delete(:center_reference); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CenterReference) ? x : ::Io::Flow::V0::Models::CenterReference.new(x)))
end

Instance Attribute Details

#center_keyObject (readonly)

Returns the value of attribute center_key.



37260
37261
37262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37260

def center_key
  @center_key
end

#center_referenceObject (readonly)

Returns the value of attribute center_reference.



37260
37261
37262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37260

def center_reference
  @center_reference
end

#contactObject (readonly)

Returns the value of attribute contact.



37260
37261
37262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37260

def contact
  @contact
end

#locationObject (readonly)

Returns the value of attribute location.



37260
37261
37262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37260

def location
  @location
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37275
37276
37277
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37275

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

#to_hashObject



37279
37280
37281
37282
37283
37284
37285
37286
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37279

def to_hash
  {
    :contact => contact.to_hash,
    :location => location.to_hash,
    :center_key => center_key,
    :center_reference => center_reference.nil? ? nil : center_reference.to_hash
  }
end

#to_jsonObject



37271
37272
37273
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37271

def to_json
  JSON.dump(to_hash)
end