Class: Mpayer::Payable
- Defined in:
- lib/mpayer_ruby/endpoints/payable.rb
Instance Attribute Summary
Attributes inherited from Endpoint
#attributes, #config, #endpoint, #id, #pagination, #response
Class Method Summary collapse
-
.all(page: 1, per_page: 100) ⇒ Object
Mpayer::Payable.all.
-
.create(options = {}) ⇒ Object
Mpayer::Payable.create(options).
-
.find(payable_id, fetch: true) ⇒ Object
Mpayer::Payable.find(id).
-
.where(ref_id:, fetch: true) ⇒ Object
Mpayer::Payable.where(ref_id:“KT0041-010000402”).
Instance Method Summary collapse
Methods inherited from Endpoint
Constructor Details
This class inherits a constructor from Mpayer::Endpoint
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Mpayer::Endpoint
Class Method Details
.all(page: 1, per_page: 100) ⇒ Object
Mpayer::Payable.all
7 8 9 10 |
# File 'lib/mpayer_ruby/endpoints/payable.rb', line 7 def all(page:1,per_page:100) url = "/payables/all" Mpayer::Fetch.get(url,query:{page:page,per_page:per_page}) end |
.create(options = {}) ⇒ Object
Mpayer::Payable.create(options)
27 28 29 30 31 |
# File 'lib/mpayer_ruby/endpoints/payable.rb', line 27 def create(={}) url = "/payables" response = Mpayer::Fetch.post(url,) payable = new(.merge!(id:response.id ,response:response)) rescue response end |
.find(payable_id, fetch: true) ⇒ Object
Mpayer::Payable.find(id)
13 14 15 16 17 |
# File 'lib/mpayer_ruby/endpoints/payable.rb', line 13 def find(payable_id,fetch:true) url = "/payables/#{payable_id}" response = Mpayer::Fetch.get(url) if fetch payable = new(id:payable_id,response:response) end |
.where(ref_id:, fetch: true) ⇒ Object
Mpayer::Payable.where(ref_id:“KT0041-010000402”)
20 21 22 23 24 |
# File 'lib/mpayer_ruby/endpoints/payable.rb', line 20 def where(ref_id:,fetch:true) url = "/payables/search/#{CGI.escape(ref_id.to_s)}" response = Mpayer::Fetch.get(url) if fetch payable = new(id:response.id,response:response) rescue response end |