Class: Finicity::V1::Request::ActivateAccounts

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#log_request, #mask_body

Constructor Details

#initialize(token, customer_id, institution_id, accounts) ⇒ ActivateAccounts

Instance Methods



21
22
23
24
25
26
# File 'lib/finicity/v1/request/activate_accounts.rb', line 21

def initialize(token, customer_id, institution_id, accounts)
  @accounts = accounts
  @customer_id = customer_id
  @institution_id = institution_id
  @token = token
end

Instance Attribute Details

#accountsObject

Attributes



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

def accounts
  @accounts
end

#customer_idObject

Attributes



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

def customer_id
  @customer_id
end

#institution_idObject

Attributes



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

def institution_id
  @institution_id
end

#tokenObject

Attributes



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

def token
  @token
end

Instance Method Details

#activate_accountsObject

The accounts parameter is the finicity representation of accounts



29
30
31
# File 'lib/finicity/v1/request/activate_accounts.rb', line 29

def activate_accounts
  http_client.put(url, body, headers)
end

#bodyObject

The accounts parameter is the finicity representation of accounts



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/finicity/v1/request/activate_accounts.rb', line 34

def body
  builder = ::Nokogiri::XML::Builder.new do |xml|
    xml.accounts {
      accounts.each do ||
        xml. {
          xml.id(.id)
          xml.number(.number)
          xml.name(.name)
          xml.type(.type)
        }
      end
    }
  end

  builder.to_xml
end

#headersObject



51
52
53
54
55
56
57
# File 'lib/finicity/v1/request/activate_accounts.rb', line 51

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

#urlObject



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/finicity/v1/request/activate_accounts.rb', line 59

def url
  ::URI.join(
    ::Finicity.config.base_url,
    'v1/',
    'customers/',
    "#{customer_id}/",
    'institutions/',
    "#{institution_id}/",
    'accounts'
  )
end