Class: Trolley::PaymentGateway
- Inherits:
-
Object
- Object
- Trolley::PaymentGateway
- Defined in:
- lib/trolley/gateways/PaymentGateway.rb
Instance Method Summary collapse
- #create(batch_id, body) ⇒ Object
- #delete(batch_id, payment_id) ⇒ Object
- #find(batch_id, payment_id) ⇒ Object
-
#initialize(client) ⇒ PaymentGateway
constructor
A new instance of PaymentGateway.
- #payment_builder(response) ⇒ Object
- #payments_list_builder(response) ⇒ Object
- #search(batch_id, page = 1, page_size = 10, term = '') ⇒ Object
- #update(batch_id, payment_id, body) ⇒ Object
Constructor Details
#initialize(client) ⇒ PaymentGateway
Returns a new instance of PaymentGateway.
5 6 7 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#create(batch_id, body) ⇒ Object
14 15 16 17 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 14 def create(batch_id, body) response = @client.post("/v1/batches/#{batch_id}/payments", body) payment_builder(response) end |
#delete(batch_id, payment_id) ⇒ Object
24 25 26 27 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 24 def delete(batch_id, payment_id) @client.delete("/v1/batches/#{batch_id}/payments/#{payment_id}") true end |
#find(batch_id, payment_id) ⇒ Object
9 10 11 12 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 9 def find(batch_id, payment_id) response = @client.get("/v1/batches/#{batch_id}/payments/#{payment_id}") payment_builder(response) end |
#payment_builder(response) ⇒ Object
34 35 36 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 34 def payment_builder(response) Utils::ResponseMapper.build(response, Payment) end |
#payments_list_builder(response) ⇒ Object
38 39 40 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 38 def payments_list_builder(response) Utils::PaginatedArray.from_response(response, Payment) end |
#search(batch_id, page = 1, page_size = 10, term = '') ⇒ Object
29 30 31 32 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 29 def search(batch_id, page = 1, page_size = 10, term = '') response = @client.get("/v1/batches/#{batch_id}/payments?page=#{page}&pageSize=#{page_size}&search=#{term}") payments_list_builder(response) end |
#update(batch_id, payment_id, body) ⇒ Object
19 20 21 22 |
# File 'lib/trolley/gateways/PaymentGateway.rb', line 19 def update(batch_id, payment_id, body) @client.patch("/v1/batches/#{batch_id}/payments/#{payment_id}", body) true end |