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.



17209
17210
17211
17212
17213
17214
17215
17216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17209

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.



17207
17208
17209
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17207

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



17207
17208
17209
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17207

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



17207
17208
17209
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17207

def number
  @number
end

#phoneObject (readonly)

Returns the value of attribute phone.



17207
17208
17209
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17207

def phone
  @phone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17222
17223
17224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17222

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

#to_hashObject



17226
17227
17228
17229
17230
17231
17232
17233
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17226

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

#to_jsonObject



17218
17219
17220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17218

def to_json
  JSON.dump(to_hash)
end