Class: PaymentRails::OfflinePaymentGateway
- Inherits:
-
Object
- Object
- PaymentRails::OfflinePaymentGateway
- Includes:
- GatewayHelper
- Defined in:
- lib/paymentrails/gateways/OfflinePaymentGateway.rb
Instance Method Summary collapse
- #create(recipient_id, body) ⇒ Object
- #delete(recipient_id, offline_payment_id) ⇒ Object
-
#initialize(client) ⇒ OfflinePaymentGateway
constructor
A new instance of OfflinePaymentGateway.
- #offline_payment_builder(response) ⇒ Object
- #offline_payments_list_builder(response) ⇒ Object
- #search(recipient_id = '', page = 1, page_size = 10, term = '') ⇒ Object
- #update(recipient_id, offline_payment_id, body) ⇒ Object
Methods included from GatewayHelper
Constructor Details
#initialize(client) ⇒ OfflinePaymentGateway
Returns a new instance of OfflinePaymentGateway.
8 9 10 |
# File 'lib/paymentrails/gateways/OfflinePaymentGateway.rb', line 8 def initialize(client) @client = client end |
Instance Method Details
#create(recipient_id, body) ⇒ Object
12 13 14 15 |
# 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) ⇒ Object
22 23 24 25 |
# 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) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# 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) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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 |
#search(recipient_id = '', page = 1, page_size = 10, term = '') ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/paymentrails/gateways/OfflinePaymentGateway.rb', line 27 def search(recipient_id = '', page = 1, page_size = 10, term = '') if recipient_id === '' response = @client.get('/v1/offline-payments?page=' + page.to_s + '&pageSize=' + page_size.to_s + '&search=' + term) else response = @client.get('/v1/recipients/' + recipient_id + '/offlinePayments?page=' + page.to_s + '&pageSize=' + page_size.to_s + '&search=' + term) end offline_payments_list_builder(response) end |
#update(recipient_id, offline_payment_id, body) ⇒ Object
17 18 19 20 |
# 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 |