Class: Increase::Resources::Accounts

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Accounts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Accounts.

Parameters:



184
185
186
# File 'lib/increase/resources/accounts.rb', line 184

def initialize(client:)
  @client = client
end

Instance Method Details

#balance(account_id, at_time: nil, request_options: {}) ⇒ Increase::Models::BalanceLookup

Retrieve the current and available balances for an account in minor units of the account's currency. Learn more about account balances.

Parameters:

  • account_id (String)

    The identifier of the Account to retrieve.

  • at_time (Time)

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

  • request_options (Increase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/increase/resources/accounts.rb', line 149

def balance(, params = {})
  parsed, options = Increase::AccountBalanceParams.dump_request(params)
  query = Increase::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["accounts/%1$s/balance", ],
    query: query,
    model: Increase::BalanceLookup,
    options: options
  )
end

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

Close an Account

Parameters:

  • account_id (String)

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

  • request_options (Increase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



172
173
174
175
176
177
178
179
# File 'lib/increase/resources/accounts.rb', line 172

def close(, params = {})
  @client.request(
    method: :post,
    path: ["accounts/%1$s/close", ],
    model: Increase::Account,
    options: params[:request_options]
  )
end

#create(name:, entity_id: nil, funding: nil, informational_entity_id: nil, loan: nil, program_id: nil, request_options: {}) ⇒ Increase::Models::Account

Create an Account

Parameters:

  • name (String)

    The name you choose for the Account.

  • entity_id (String)

    The identifier for the Entity that will own the Account.

  • funding (Symbol, Increase::Models::AccountCreateParams::Funding)

    Whether the Account is funded by a loan or by deposits.

  • informational_entity_id (String)

    The identifier of an Entity that, while not owning the Account, is associated with its activity. This is generally the beneficiary of the funds.

  • loan (Increase::Models::AccountCreateParams::Loan)

    The loan details for the account.

  • program_id (String)

    The identifier for the Program that this Account falls under. Required if your Group operates more than one Program. List your Programs to find their identifiers.

  • request_options (Increase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
# File 'lib/increase/resources/accounts.rb', line 33

def create(params)
  parsed, options = Increase::AccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "accounts",
    body: parsed,
    model: Increase::Account,
    options: options
  )
end

#list(created_at: nil, cursor: nil, entity_id: nil, idempotency_key: nil, informational_entity_id: nil, limit: nil, program_id: nil, status: nil, request_options: {}) ⇒ Increase::Internal::Page<Increase::Models::Account>

List Accounts

Parameters:

  • created_at (Increase::Models::AccountListParams::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.

  • program_id (String)

    Filter Accounts for those in a specific Program.

  • status (Increase::Models::AccountListParams::Status)
  • request_options (Increase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/increase/resources/accounts.rb', line 122

def list(params = {})
  parsed, options = Increase::AccountListParams.dump_request(params)
  query = Increase::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "accounts",
    query: query,
    page: Increase::Internal::Page,
    model: Increase::Account,
    options: options
  )
end

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

Retrieve an Account

Parameters:

  • account_id (String)

    The identifier of the Account to retrieve.

  • request_options (Increase::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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

def retrieve(, params = {})
  @client.request(
    method: :get,
    path: ["accounts/%1$s", ],
    model: Increase::Account,
    options: params[:request_options]
  )
end

#update(account_id, loan: nil, name: nil, request_options: {}) ⇒ Increase::Models::Account

Update an Account

Parameters:

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
# File 'lib/increase/resources/accounts.rb', line 79

def update(, params = {})
  parsed, options = Increase::AccountUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["accounts/%1$s", ],
    body: parsed,
    model: Increase::Account,
    options: options
  )
end