class PaymentRails::OfflinePaymentGateway

Public Class Methods

new(client) click to toggle source
# File lib/paymentrails/gateways/OfflinePaymentGateway.rb, line 8
def initialize(client)
  @client = client
end

Public Instance Methods

create(recipient_id, body) click to toggle source
# File lib/paymentrails/gateways/OfflinePaymentGateway.rb, line 12
def create(recipient_id, body)
  response = @client.post('/v1/recipients/' + recipient_id + '/offlinePayments', body)
  offline_payment_builder(response)
end
delete(recipient_id, offline_payment_id) click to toggle source
# File lib/paymentrails/gateways/OfflinePaymentGateway.rb, line 22
def delete(recipient_id, offline_payment_id)
  @client.delete('/v1/recipients/' + recipient_id + '/offlinePayments/' + offline_payment_id)
  true
end
offline_payment_builder(response) click to toggle source
# File lib/paymentrails/gateways/OfflinePaymentGateway.rb, line 37
def offline_payment_builder(response)
  offline_payment = OfflinePayment.new
  data = JSON.parse(response)
  data.each do |key, value|
    next unless key === 'offlinePayment'
    loosely_hydrate_model(offline_payment, value)
  end
  offline_payment
end
offline_payments_list_builder(response) click to toggle source
# File lib/paymentrails/gateways/OfflinePaymentGateway.rb, line 47
def offline_payments_list_builder(response)
  offline_payments = []
  data = JSON.parse(response)

  data.each do |key, value|
    next unless key === 'offlinePayments'
    value.each do |newKey, _newValue|
      offline_payment = loosely_hydrate_model(OfflinePayment.new, newKey)
      offline_payments.push(offline_payment)
    end
  end
  offline_payments
end
update(recipient_id, offline_payment_id, body) click to toggle source
# File lib/paymentrails/gateways/OfflinePaymentGateway.rb, line 17
def update(recipient_id, offline_payment_id, body)
  @client.patch('/v1/recipients/' + recipient_id + '/offlinePayments/' + offline_payment_id, body)
  true
end