Class: PaymentRails::RecipientAccountGateway

Inherits:
Object
  • Object
show all
Includes:
GatewayHelper
Defined in:
lib/paymentrails/gateways/RecipientAccountGateway.rb

Instance Method Summary collapse

Methods included from GatewayHelper

#loosely_hydrate_model

Constructor Details

#initialize(client) ⇒ RecipientAccountGateway

Returns a new instance of RecipientAccountGateway.



8
9
10
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#all(recipient_id) ⇒ Object



17
18
19
20
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 17

def all(recipient_id)
  response = @client.get('/v1/recipients/' + recipient_id + '/accounts/')
  (response)
end

#create(recipient_id, body) ⇒ Object



22
23
24
25
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 22

def create(recipient_id, body)
  response = @client.post('/v1/recipients/' + recipient_id + '/accounts', body)
  (response)
end

#delete(recipient_id, recipient_account_id) ⇒ Object



32
33
34
35
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 32

def delete(recipient_id, )
  @client.delete('/v1/recipients/' + recipient_id + '/accounts/' + )
  true
end

#find(recipient_id, recipient_account_id) ⇒ Object



12
13
14
15
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 12

def find(recipient_id, )
  response = @client.get('/v1/recipients/' + recipient_id + '/accounts/' + )
  (response)
end

#recipient_account_builder(response) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 37

def (response)
   = RecipientAccount.new
  data = JSON.parse(response)
  data.each do |key, value|
    next unless key === 'account'
    loosely_hydrate_model(, value)
  end
  
end

#recipient_account_list_builder(response) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 47

def (response)
  recipient_accounts = []
  data = JSON.parse(response)

  data.each do |key, value|
    next unless key === 'accounts'
    value.each do |newKey, _newValue|
       = loosely_hydrate_model(RecipientAccount.new, newKey)
      recipient_accounts.push()
    end
  end
  recipient_accounts
end

#update(recipient_id, recipient_account_id, body) ⇒ Object



27
28
29
30
# File 'lib/paymentrails/gateways/RecipientAccountGateway.rb', line 27

def update(recipient_id, , body)
  response = @client.patch('/v1/recipients/' + recipient_id + '/accounts/' + , body)
  (response)
end