Class: Mpayer::Client
- Defined in:
- lib/mpayer_ruby/endpoints/client.rb
Instance Attribute Summary collapse
-
#account(account_id = nil, client_id = id) ⇒ Object
Mpayer::Client.find(id:20284).account(accountsid).
-
#accounts(page: 1, per_page: 100) ⇒ Object
Mpayer::Client.find(26, fetch:false).accounts(page:1,per_page:100).
-
#payables(page: 1, per_page: 100) ⇒ Object
Mpayer::Client.find(26, fetch:false).payables(page:1,per_page:100).
-
#transactions(account_id, page: 1, per_page: 100) ⇒ Object
Mpayer::Client.find(26, fetch:false).transactions(account_id, page:1,per_page:100).
Attributes inherited from Endpoint
#attributes, #config, #endpoint, #id, #pagination, #response
Class Method Summary collapse
-
.all(page: 1, per_page: 100) ⇒ Object
Mpayer::Client.all.
-
.create(options = {}) ⇒ Object
client_attributes = { client_name: “Kiki Lolo”, client_birthday: Time.zone.now.iso8601, client_type: “ext”, ac_type: “cu”,client_mobile: ‘073373932’, client_email: ‘[email protected]’,currency: “kes”, mandate:“s”, sub_type: “od” } Mpayer::Client.create(client_attributes).
-
.find(client_id, fetch: true) ⇒ Object
Mpayer::Client.find(id).
Instance Method Summary collapse
-
#create_account(options = {}) ⇒ Object
Mpayer::Client.find(id:20284).create_account(options).
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
Instance Attribute Details
#account(account_id = nil, client_id = id) ⇒ Object
Mpayer::Client.find(id:20284).account(accountsid)
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mpayer_ruby/endpoints/client.rb', line 32 def account(account_id=nil,client_id=id) account_id ||= @account.id rescue nil raise "Arguments missing: account_id or client_id" if client_id.nil? or account_id.nil? url = "/clients/#{client_id}/accounts/#{account_id}" if (@account.id == account_id rescue false) @account ||= Mpayer::Fetch.get(url) else @account = Mpayer::Fetch.get(url) end end |
#accounts(page: 1, per_page: 100) ⇒ Object
Mpayer::Client.find(26, fetch:false).accounts(page:1,per_page:100)
51 52 53 |
# File 'lib/mpayer_ruby/endpoints/client.rb', line 51 def accounts(page:1,per_page:100) find_all(page:page,per_page:per_page) end |
#payables(page: 1, per_page: 100) ⇒ Object
Mpayer::Client.find(26, fetch:false).payables(page:1,per_page:100)
56 57 58 |
# File 'lib/mpayer_ruby/endpoints/client.rb', line 56 def payables(page:1,per_page:100) find_all(page:page,per_page:per_page) end |
#transactions(account_id, page: 1, per_page: 100) ⇒ Object
Mpayer::Client.find(26, fetch:false).transactions(account_id, page:1,per_page:100)
61 62 63 |
# File 'lib/mpayer_ruby/endpoints/client.rb', line 61 def transactions(account_id,page:1,per_page:100) find_all(page:page,per_page:per_page,account_id:account_id) end |
Class Method Details
.all(page: 1, per_page: 100) ⇒ Object
Mpayer::Client.all
8 9 10 11 |
# File 'lib/mpayer_ruby/endpoints/client.rb', line 8 def all(page:1,per_page:100) url = "/clients/all_clients" Mpayer::Fetch.get(url,query:{page:page,per_page:per_page}) end |
.create(options = {}) ⇒ Object
client_attributes = { client_name: “Kiki Lolo”, client_birthday: Time.zone.now.iso8601, client_type: “ext”, ac_type: “cu”,client_mobile: ‘073373932’, client_email: ‘[email protected]’,currency: “kes”, mandate:“s”, sub_type: “od” } Mpayer::Client.create(client_attributes)
22 23 24 25 26 27 |
# File 'lib/mpayer_ruby/endpoints/client.rb', line 22 def create(={}) url = "/clients" # bp response = Mpayer::Fetch.post(url,) client = new(.merge!(id:response.id ,response:response, account: response.account.first)) rescue response end |