Class: SlimpayClient::Resource
- Defined in:
- lib/slimpay_client/resource.rb
Overview
An abstract resource to be inherited from.
Defines API resource non-semantic methods.
Direct Known Subclasses
App, Card, CardAlias, Creditor, DirectDebit, Mandate, Order, Payment, RecurrentCardTransaction, RecurrentDirectDebit
Instance Method Summary collapse
-
#get_one(reference = 1) ⇒ Object
Shortcut method to get a resource with only resource’s reference.
-
#initialize ⇒ Resource
constructor
A new instance of Resource.
Methods inherited from Base
Constructor Details
#initialize ⇒ Resource
Returns a new instance of Resource.
6 7 8 9 |
# File 'lib/slimpay_client/resource.rb', line 6 def initialize @resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize super end |
Instance Method Details
#get_one(reference = 1) ⇒ Object
Shortcut method to get a resource with only resource’s reference.
The above example shall return the same result as
mandates = SlimpayClient::Mandate.new
mandates.get_mandates({creditorReference: @creditor_reference, reference: 1})
Example:
mandates = SlimpayClient::Mandate.new
mandates.get_one(1)
Arguments:
reference: (String)
22 23 24 25 26 27 |
# File 'lib/slimpay_client/resource.rb', line 22 def get_one(reference = 1) url = "#{@endpoint}/creditors/#{@creditor_reference}/#{@resource_name}/#{reference}" response = HTTParty.get(url, headers: ) generate_api_methods(JSON.parse(response.body)) SlimpayClient.answer(response) end |