Class: Billingrails::Resources::Accounts
- Inherits:
-
Object
- Object
- Billingrails::Resources::Accounts
- Defined in:
- lib/billingrails/resources/accounts.rb
Overview
Accounts resource
Instance Method Summary collapse
-
#create(data) ⇒ Hash
Create an account.
-
#debit(id, data) ⇒ Hash
Debit balance.
-
#get_balances(id, params: nil) ⇒ Hash
Get balances.
-
#initialize(client) ⇒ Accounts
constructor
A new instance of Accounts.
-
#list(params: nil) ⇒ Hash
List accounts.
-
#retrieve(id, params: nil) ⇒ Hash
Retrieve an account.
-
#update(id, data) ⇒ Hash
Update an account.
Constructor Details
#initialize(client) ⇒ Accounts
Returns a new instance of Accounts.
10 11 12 |
# File 'lib/billingrails/resources/accounts.rb', line 10 def initialize(client) @client = client end |
Instance Method Details
#create(data) ⇒ Hash
Create an account
Creates an account.
31 32 33 34 |
# File 'lib/billingrails/resources/accounts.rb', line 31 def create(data) path = "/accounts" @client.request(:post, path, body: data) end |
#debit(id, data) ⇒ Hash
Debit balance
Debits an account’s balance.
79 80 81 82 |
# File 'lib/billingrails/resources/accounts.rb', line 79 def debit(id, data) path = "/accounts/#{id}/debit" @client.request(:post, path, body: data) end |
#get_balances(id, params: nil) ⇒ Hash
Get balances
Retrieve credit balances for an account.
67 68 69 70 |
# File 'lib/billingrails/resources/accounts.rb', line 67 def get_balances(id, params: nil) path = "/accounts/#{id}/balances" @client.request(:get, path, params: params) end |
#list(params: nil) ⇒ Hash
List accounts
Retrieve a list of accounts.
20 21 22 23 |
# File 'lib/billingrails/resources/accounts.rb', line 20 def list(params: nil) path = "/accounts" @client.request(:get, path, params: params) end |
#retrieve(id, params: nil) ⇒ Hash
Retrieve an account
Retrieves an account by ID.
43 44 45 46 |
# File 'lib/billingrails/resources/accounts.rb', line 43 def retrieve(id, params: nil) path = "/accounts/#{id}" @client.request(:get, path, params: params) end |
#update(id, data) ⇒ Hash
Update an account
Updates an account.
55 56 57 58 |
# File 'lib/billingrails/resources/accounts.rb', line 55 def update(id, data) path = "/accounts/#{id}" @client.request(:put, path, body: data) end |