Class: Increase::Resources::Accounts

Inherits:
Object
  • Object
show all
Defined in:
lib/increase/resources/accounts.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Accounts

Returns a new instance of Accounts.



6
7
8
# File 'lib/increase/resources/accounts.rb', line 6

def initialize(client:)
  @client = client
end

Instance Method Details

#balance(account_id, params = {}, opts = {}) ⇒ Increase::Models::BalanceLookup

Retrieve an Account Balance

Parameters:

  • account_id (String)

    The identifier of the Account to retrieve.

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :at_time (String)

    The moment to query the balance at. If not set, returns the current balances.

Returns:



103
104
105
106
107
108
109
110
# File 'lib/increase/resources/accounts.rb', line 103

def balance(, params = {}, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/accounts/#{}/balance"
  req[:query] = params
  req[:model] = Increase::Models::BalanceLookup
  @client.request(req, opts)
end

#close(account_id, opts = {}) ⇒ Increase::Models::Account

Close an Account

Parameters:

  • account_id (String)

    The identifier of the Account to close. The account must have a zero balance.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



118
119
120
121
122
123
124
# File 'lib/increase/resources/accounts.rb', line 118

def close(, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/accounts/#{}/close"
  req[:model] = Increase::Models::Account
  @client.request(req, opts)
end

#create(params = {}, opts = {}) ⇒ Increase::Models::Account

Create an Account

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :name (String)

    The name you choose for the Account.

  • :entity_id (String)

    The identifier for the Entity that will own the Account.

  • :informational_entity_id (String)

    The identifier of an Entity that, while not owning the Account, is associated with its activity. Its relationship to your group must be informational.

  • :program_id (String)

    The identifier for the Program that this Account falls under. Required if you operate more than one Program.

Returns:



23
24
25
26
27
28
29
30
# File 'lib/increase/resources/accounts.rb', line 23

def create(params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/accounts"
  req[:body] = params
  req[:model] = Increase::Models::Account
  @client.request(req, opts)
end

#list(params = {}, opts = {}) ⇒ Increase::Page<Increase::Models::Account>

List Accounts

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :created_at (CreatedAt)
  • :cursor (String)

    Return the page of entries after this one.

  • :entity_id (String)

    Filter Accounts for those belonging to the specified Entity.

  • :idempotency_key (String)

    Filter records to the one with the specified idempotency_key you chose for that object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about idempotency.

  • :informational_entity_id (String)

    Filter Accounts for those belonging to the specified Entity as informational.

  • :limit (Integer)

    Limit the size of the list that is returned. The default (and maximum) is 100 objects.

  • :status (Symbol)

    Filter Accounts for those with the specified status.

Returns:



83
84
85
86
87
88
89
90
91
# File 'lib/increase/resources/accounts.rb', line 83

def list(params = {}, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/accounts"
  req[:query] = params
  req[:page] = Increase::Page
  req[:model] = Increase::Models::Account
  @client.request(req, opts)
end

#retrieve(account_id, opts = {}) ⇒ Increase::Models::Account

Retrieve an Account

Parameters:

  • account_id (String)

    The identifier of the Account to retrieve.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



38
39
40
41
42
43
44
# File 'lib/increase/resources/accounts.rb', line 38

def retrieve(, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/accounts/#{}"
  req[:model] = Increase::Models::Account
  @client.request(req, opts)
end

#update(account_id, params = {}, opts = {}) ⇒ Increase::Models::Account

Update an Account

Parameters:

  • account_id (String)

    The identifier of the Account to update.

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :name (String)

    The new name of the Account.

Returns:



56
57
58
59
60
61
62
63
# File 'lib/increase/resources/accounts.rb', line 56

def update(, params = {}, opts = {})
  req = {}
  req[:method] = :patch
  req[:path] = "/accounts/#{}"
  req[:body] = params
  req[:model] = Increase::Models::Account
  @client.request(req, opts)
end