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.
79 80 81 82 |
# File 'lib/billingrails/resources/accounts.rb', line 79 def create(data) path = "/accounts" @client.request(:post, path, body: data) end |
#debit(id, data) ⇒ Hash
Debit balance
Debits an account’s balance.
45 46 47 48 |
# File 'lib/billingrails/resources/accounts.rb', line 45 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.
57 58 59 60 |
# File 'lib/billingrails/resources/accounts.rb', line 57 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.
68 69 70 71 |
# File 'lib/billingrails/resources/accounts.rb', line 68 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.
21 22 23 24 |
# File 'lib/billingrails/resources/accounts.rb', line 21 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.
33 34 35 36 |
# File 'lib/billingrails/resources/accounts.rb', line 33 def update(id, data) path = "/accounts/#{id}" @client.request(:put, path, body: data) end |