Class: RecipientAccountGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/RecipientAccountGateway.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ RecipientAccountGateway

Returns a new instance of RecipientAccountGateway.



4
5
6
# File 'lib/RecipientAccountGateway.rb', line 4

def initialize(client)
  @client = client
end

Instance Method Details

#all(recipient_id) ⇒ Object



13
14
15
16
# File 'lib/RecipientAccountGateway.rb', line 13

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

#create(recipient_id, body) ⇒ Object



18
19
20
21
# File 'lib/RecipientAccountGateway.rb', line 18

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

#delete(recipient_id, recipient_account_id) ⇒ Object



28
29
30
31
# File 'lib/RecipientAccountGateway.rb', line 28

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

#find(recipient_id, recipient_account_id) ⇒ Object



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

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

#recipient_account_builder(response) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/RecipientAccountGateway.rb', line 33

def (response)
   = RecipientAccount.new
  data = JSON.parse(response)
  data.each do |key, value|
    next unless key === 'account'
    value.each do |recipKey, recipValue|
      .send("#{recipKey}=", recipValue)
    end
  end
  
end

#recipient_account_list_builder(response) ⇒ Object



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

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

  data.each do |key, value|
    next unless key === 'accounts'
    value.each do |newKey, _newValue|
       = RecipientAccount.new
      newKey.each do |key1, value1|
        .send("#{key1}=", value1)
      end
      recipient_accounts.push()
    end
  end
  recipient_accounts
end

#update(recipient_id, recipient_account_id, body) ⇒ Object



23
24
25
26
# File 'lib/RecipientAccountGateway.rb', line 23

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