Class: PaymentRails::InvoiceGateway
- Inherits:
-
Object
- Object
- PaymentRails::InvoiceGateway
- Includes:
- GatewayHelper
- Defined in:
- lib/paymentrails/gateways/InvoiceGateway.rb
Instance Method Summary collapse
- #create(body) ⇒ Object
- #create_line(body) ⇒ Object
- #delete(body) ⇒ Object
- #delete_line(body) ⇒ Object
- #find(body) ⇒ Object
-
#initialize(client) ⇒ InvoiceGateway
constructor
A new instance of InvoiceGateway.
- #invoice_builder(response) ⇒ Object
- #invoice_list_builder(response) ⇒ Object
- #search(body) ⇒ Object
- #update(body) ⇒ Object
- #update_line(body) ⇒ Object
Methods included from GatewayHelper
Constructor Details
#initialize(client) ⇒ InvoiceGateway
Returns a new instance of InvoiceGateway.
8 9 10 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 8 def initialize(client) @client = client end |
Instance Method Details
#create(body) ⇒ Object
17 18 19 20 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 17 def create(body) response = @client.post('/v1/invoices/create', body) invoice_builder(response) end |
#create_line(body) ⇒ Object
22 23 24 25 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 22 def create_line(body) response = @client.post('/v1/invoices/create-lines', body) invoice_builder(response) end |
#delete(body) ⇒ Object
42 43 44 45 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 42 def delete(body) @client.post('/v1/invoices/delete', body) true end |
#delete_line(body) ⇒ Object
47 48 49 50 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 47 def delete_line(body) @client.post('/v1/invoices/delete-lines', body) true end |
#find(body) ⇒ Object
12 13 14 15 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 12 def find(body) response = @client.post('/v1/invoices/get', body) invoice_builder(response) end |
#invoice_builder(response) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 52 def invoice_builder(response) invoice = Invoice.new data = JSON.parse(response) data.each do |key, value| next unless key === 'invoice' loosely_hydrate_model(invoice, value) end invoice end |
#invoice_list_builder(response) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 62 def invoice_list_builder(response) invoices = [] data = JSON.parse(response) data.each do |key, value| next unless key === 'invoices' value.each do |newKey, _newValue| invoices.push( loosely_hydrate_model(Invoice.new, newKey) ) end end invoices end |
#search(body) ⇒ Object
27 28 29 30 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 27 def search(body) response = @client.post('/v1/invoices/search', body) invoice_list_builder(response) end |
#update(body) ⇒ Object
32 33 34 35 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 32 def update(body) @client.post('/v1/invoices/update', body) true end |
#update_line(body) ⇒ Object
37 38 39 40 |
# File 'lib/paymentrails/gateways/InvoiceGateway.rb', line 37 def update_line(body) @client.post('/v1/invoices/update-lines', body) true end |