class PaymentRails::PaymentGateway
Public Class Methods
new(client)
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 8 def initialize(client) @client = client end
Public Instance Methods
create(batch_id, body)
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 17 def create(batch_id, body) response = @client.post('/v1/batches/' + batch_id + '/payments', body) payment_builder(response) end
delete(batch_id, payment_id)
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 27 def delete(batch_id, payment_id) @client.delete('/v1/batches/' + batch_id + '/payments/' + payment_id) true end
find(batch_id, payment_id)
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 12 def find(batch_id, payment_id) response = @client.get('/v1/batches/' + batch_id + '/payments/' + payment_id) payment_builder(response) end
payment_builder(response)
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 37 def payment_builder(response) payment = Payment.new data = JSON.parse(response) data.each do |key, value| next unless key === 'payment' loosely_hydrate_model(payment, value) end payment end
payments_list_builder(response)
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 47 def payments_list_builder(response) payments = [] data = JSON.parse(response) data.each do |key, value| next unless key === 'payments' value.each do |newKey, _newValue| payment = loosely_hydrate_model(Payment.new, newKey) payments.push(payment) end end payments end
search(batch_id, page = 1, page_size = 10, term = '')
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 32 def search(batch_id, page = 1, page_size = 10, term = '') response = @client.get('/v1/batches/' + batch_id.to_s + '/payments?page=' + page.to_s + '&pageSize=' + page_size.to_s + '&search=' + term) payments_list_builder(response) end
update(batch_id, payment_id, body)
click to toggle source
# File lib/paymentrails/gateways/PaymentGateway.rb, line 22 def update(batch_id, payment_id, body) @client.patch('/v1/batches/' + batch_id + '/payments/' + payment_id, body) true end