Class: Io::Flow::V0::Models::CustomerAddressBookContact

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

Overview

Preferences may indicate a contact is preferred for billing, invoicing, and/or shipping.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CustomerAddressBookContact

Returns a new instance of CustomerAddressBookContact.



34977
34978
34979
34980
34981
34982
34983
34984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34977

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :address, :contact, :address_preferences], 'CustomerAddressBookContact')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @contact = (x = opts.delete(:contact); x.is_a?(::Io::Flow::V0::Models::Contact) ? x : ::Io::Flow::V0::Models::Contact.new(x))
  @address_preferences = HttpClient::Preconditions.assert_class('address_preferences', opts.delete(:address_preferences), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::CustomerAddressPreference) ? x : ::Io::Flow::V0::Models::CustomerAddressPreference.new(x)) }
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



34975
34976
34977
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34975

def address
  @address
end

#address_preferencesObject (readonly)

Returns the value of attribute address_preferences.



34975
34976
34977
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34975

def address_preferences
  @address_preferences
end

#contactObject (readonly)

Returns the value of attribute contact.



34975
34976
34977
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34975

def contact
  @contact
end

#idObject (readonly)

Returns the value of attribute id.



34975
34976
34977
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34975

def id
  @id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34990
34991
34992
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34990

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

#to_hashObject



34994
34995
34996
34997
34998
34999
35000
35001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34994

def to_hash
  {
    :id => id,
    :address => address.to_hash,
    :contact => contact.to_hash,
    :address_preferences => address_preferences.map { |o| o.to_hash }
  }
end

#to_jsonObject



34986
34987
34988
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34986

def to_json
  JSON.dump(to_hash)
end