Class: Finicity::V1::Request::ActivateAccountsWithMfa

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#log_request, #mask_body

Constructor Details

#initialize(token, mfa_session, customer_id, institution_id, accounts, mfa_credentials) ⇒ ActivateAccountsWithMfa

Instance Methods



23
24
25
26
27
28
29
30
# File 'lib/finicity/v1/request/activate_accounts_with_mfa.rb', line 23

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

Instance Attribute Details

#accountsObject

Attributes



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

def accounts
  @accounts
end

#customer_idObject

Attributes



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

def customer_id
  @customer_id
end

#institution_idObject

Attributes



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

def institution_id
  @institution_id
end

#mfa_credentialsObject

Attributes



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

def mfa_credentials
  @mfa_credentials
end

#mfa_sessionObject

Attributes



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

def mfa_session
  @mfa_session
end

#tokenObject

Attributes



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

def token
  @token
end

Instance Method Details

#activate_accounts_with_mfaObject



32
33
34
# File 'lib/finicity/v1/request/activate_accounts_with_mfa.rb', line 32

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

#bodyObject

The accounts parameter is the finicity representation of accounts



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/finicity/v1/request/activate_accounts_with_mfa.rb', line 37

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
      xml.mfaChallenges {
        xml.questions {
          mfa_credentials.each do |mfa_credential|
            xml.question {
              xml.text_(mfa_credential[:text])
              xml.answer(mfa_credential[:answer])
            }
          end
        }
      }
    }
  end

  builder.to_xml
end

#headersObject



64
65
66
67
68
69
70
71
# File 'lib/finicity/v1/request/activate_accounts_with_mfa.rb', line 64

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

#urlObject



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/finicity/v1/request/activate_accounts_with_mfa.rb', line 73

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