Class: Io::Flow::V0::Models::Customer

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

Overview

A customer represents the actual person purchasing from you. This information is needed primarily to support logistics (delivery to this person), fraud management (verification of who the person is), and reporting. We also recommend including your customer number whenever possible as doing so will allow Flow to link up transactions for this customer making customer service easier.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Customer



22681
22682
22683
22684
22685
22686
22687
22688
22689
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22681

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name], 'Customer')
  @name = (x = opts.delete(:name); x.is_a?(::Io::Flow::V0::Models::Name) ? x : ::Io::Flow::V0::Models::Name.new(x))
  @number = (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, String))
  @phone = (x = opts.delete(:phone); x.nil? ? nil : HttpClient::Preconditions.assert_class('phone', x, String))
  @email = (x = opts.delete(:email); x.nil? ? nil : HttpClient::Preconditions.assert_class('email', x, String))
  @address = (x = opts.delete(:address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingAddress) ? x : ::Io::Flow::V0::Models::BillingAddress.new(x)))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



22679
22680
22681
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22679

def address
  @address
end

#emailObject (readonly)

Returns the value of attribute email.



22679
22680
22681
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22679

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



22679
22680
22681
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22679

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



22679
22680
22681
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22679

def number
  @number
end

#phoneObject (readonly)

Returns the value of attribute phone.



22679
22680
22681
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22679

def phone
  @phone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22695
22696
22697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22695

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

#to_hashObject



22699
22700
22701
22702
22703
22704
22705
22706
22707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22699

def to_hash
  {
    :name => name.to_hash,
    :number => number,
    :phone => phone,
    :email => email,
    :address => address.nil? ? nil : address.to_hash
  }
end

#to_jsonObject



22691
22692
22693
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22691

def to_json
  JSON.dump(to_hash)
end