class PaymentRails::RecipientGateway
Public Class Methods
new(client)
click to toggle source
# File lib/paymentrails/gateways/RecipientGateway.rb, line 8 def initialize(client) @client = client end
Public Instance Methods
create(body)
click to toggle source
# File lib/paymentrails/gateways/RecipientGateway.rb, line 17 def create(body) response = @client.post('/v1/recipients/', body) recipient_builder(response) end
delete(recipient_id)
click to toggle source
# File lib/paymentrails/gateways/RecipientGateway.rb, line 27 def delete(recipient_id) @client.delete('/v1/recipients/' + recipient_id) true end
find(recipient_id)
click to toggle source
# File lib/paymentrails/gateways/RecipientGateway.rb, line 12 def find(recipient_id) response = @client.get('/v1/recipients/' + recipient_id) recipient_builder(response) end
recipient_builder(response)
click to toggle source
# File lib/paymentrails/gateways/RecipientGateway.rb, line 44 def recipient_builder(response) recipient = Recipient.new data = JSON.parse(response) data.each do |key, value| next unless key === 'recipient' loosely_hydrate_model(recipient, value) end recipient end
recipient_list_builder(response)
click to toggle source
# File lib/paymentrails/gateways/RecipientGateway.rb, line 54 def recipient_list_builder(response) recipients = [] data = JSON.parse(response) data.each do |key, value| next unless key === 'recipients' value.each do |newKey, _newValue| recipient = loosely_hydrate_model(Recipient.new, newKey) recipients.push(recipient) end end recipients end
search(page = 1, page_size = 10, prefix_search = '', filters = {})
click to toggle source
TODO: if we can afford a breaking change ideally these should be kwargs
# File lib/paymentrails/gateways/RecipientGateway.rb, line 33 def search(page = 1, page_size = 10, prefix_search = '', filters = {}) query_string = URI.encode_www_form( page: page.to_s, pageSize: page_size.to_s, search: prefix_search, **filters ) response = @client.get("/v1/recipients?#{query_string}") recipient_list_builder(response) end
update(recipient_id, body)
click to toggle source
# File lib/paymentrails/gateways/RecipientGateway.rb, line 22 def update(recipient_id, body) @client.patch('/v1/recipients/' + recipient_id, body) true end