Class: SlimpayClient::Payment
- Defined in:
- lib/slimpay_client/payment.rb
Overview
An abstract Payment to be inherited from.
Defines API Payment non-semantic methods.
Instance Method Summary collapse
- #cancel(id) ⇒ Object
- #get_one(id = 1) ⇒ Object
-
#initialize ⇒ Payment
constructor
A new instance of Payment.
- #issues(id = 1) ⇒ Object
- #refund(id, amount) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ Payment
Returns a new instance of Payment.
6 7 8 9 |
# File 'lib/slimpay_client/payment.rb', line 6 def initialize @resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize super end |
Instance Method Details
#cancel(id) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/slimpay_client/payment.rb', line 32 def cancel(id) url = "payments/#{id}/cancellation" = {} response = HTTParty.post("#{@endpoint}/#{url}", body: .to_json, headers: ) follow_up_api(response) end |
#get_one(id = 1) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/slimpay_client/payment.rb', line 11 def get_one(id = 1) url = "#{@endpoint}/payments/#{id}" response = HTTParty.get(url, headers: ) generate_api_methods(JSON.parse(response.body)) SlimpayClient.answer(response) end |
#issues(id = 1) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/slimpay_client/payment.rb', line 18 def issues(id = 1) url = "#{@endpoint}/payments/#{id}/issues" response = HTTParty.get(url, headers: ) generate_api_methods(JSON.parse(response.body)) SlimpayClient.answer(response) end |
#refund(id, amount) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/slimpay_client/payment.rb', line 25 def refund(id, amount) url = "payments/#{id}/refund" = {amount: amount} response = HTTParty.post("#{@endpoint}/#{url}", body: .to_json, headers: ) follow_up_api(response) end |