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

Returns a new instance of Customer.



16828
16829
16830
16831
16832
16833
16834
16835
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16828

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))
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



16826
16827
16828
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16826

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



16826
16827
16828
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16826

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



16826
16827
16828
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16826

def number
  @number
end

#phoneObject (readonly)

Returns the value of attribute phone.



16826
16827
16828
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16826

def phone
  @phone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16841
16842
16843
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16841

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

#to_hashObject



16845
16846
16847
16848
16849
16850
16851
16852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16845

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

#to_jsonObject



16837
16838
16839
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16837

def to_json
  JSON.dump(to_hash)
end