Class: CreditGateway::BankRepository

Inherits:
BaseRepository show all
Defined in:
lib/credit_gateway/bank_repository.rb

Instance Method Summary collapse

Methods inherited from BaseRepository

#initialize

Constructor Details

This class inherits a constructor from CreditGateway::BaseRepository

Instance Method Details

#create_connection(subject_id, connection_params:) ⇒ Object

connection_params - CreditGateway::BankConnectionParams



25
26
27
28
29
30
31
32
33
# File 'lib/credit_gateway/bank_repository.rb', line 25

def create_connection(subject_id, connection_params:)
  url = format_url(
    '/bank/subjects/:subject_id/connections',
    subject_id: subject_id.to_s
  )
  result = post(url, params: connection_params.as_json)

  BankConnection.build(json: result.body)
end

#create_subject(company_id) ⇒ Object



10
11
12
13
14
# File 'lib/credit_gateway/bank_repository.rb', line 10

def create_subject(company_id)
  result = post('/bank/subjects', params: { companyId: company_id })

  BankSubject.build(json: result.body)
end

#lookup_subjects(company_id) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/credit_gateway/bank_repository.rb', line 16

def lookup_subjects(company_id)
  result = get('/bank/subjects', params: { companyId: company_id })

  result.body.fetch(:data, []).map do |subject|
    BankSubject.build(json: subject)
  end
end

#upload_bank_data(subject_id, connection_id, bank_data_request) ⇒ Object

Submits bank data to prepare the report bank_data_request - CreditGateway::BankDataRequest



37
38
39
40
41
42
43
44
45
46
# File 'lib/credit_gateway/bank_repository.rb', line 37

def upload_bank_data(subject_id, connection_id, bank_data_request)
  url = format_url(
    '/bank/subjects/:subject_id/connections/:connection_id/upload',
    subject_id: subject_id.to_s,
    connection_id: connection_id.to_s
  )
  post(url, params: bank_data_request.as_json)

  true
end