Class: Finicity::V1::Request::AddCustomer

Inherits:
Object
  • Object
show all
Extended by:
HTTPClient::IncludeClient
Includes:
Logger
Defined in:
lib/finicity/v1/request/add_customer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#log_request, #mask_body

Constructor Details

#initialize(token, user_guid) ⇒ AddCustomer

Instance Methods



19
20
21
22
# File 'lib/finicity/v1/request/add_customer.rb', line 19

def initialize(token, user_guid)
  @token = token
  @user_guid = user_guid
end

Instance Attribute Details

#tokenObject

Attributes



13
14
15
# File 'lib/finicity/v1/request/add_customer.rb', line 13

def token
  @token
end

#user_guidObject

Attributes



13
14
15
# File 'lib/finicity/v1/request/add_customer.rb', line 13

def user_guid
  @user_guid
end

Instance Method Details

#add_customerObject



24
25
26
# File 'lib/finicity/v1/request/add_customer.rb', line 24

def add_customer
  http_client.post(url, body, headers)
end

#bodyObject



28
29
30
31
32
33
34
35
# File 'lib/finicity/v1/request/add_customer.rb', line 28

def body
  {
    'username' => user_guid,
    'email' => "#{user_guid}@mx.com",
    'firstName' => user_guid,
    'lastName' => user_guid
  }.to_xml(:root => 'customer')
end

#headersObject



37
38
39
40
41
42
43
# File 'lib/finicity/v1/request/add_customer.rb', line 37

def headers
  {
    'Finicity-App-Key' => ::Finicity.config.app_key,
    'Finicity-App-Token' => token,
    'Content-Type' => 'application/xml'
  }
end

#urlObject



45
46
47
48
49
50
51
52
# File 'lib/finicity/v1/request/add_customer.rb', line 45

def url
  ::URI.join(
    ::Finicity.config.base_url,
    'v1/',
    'customers/',
    'active'
  )
end