Module: Unit::Account::Credit

Defined in:
lib/unit/models/account/account.rb,
lib/unit/models/account/credit/list_account_params.rb,
lib/unit/models/account/credit/close_account_request.rb,
lib/unit/models/account/credit/patch_account_request.rb,
lib/unit/models/account/credit/create_account_request.rb,
lib/unit/models/account/credit/freeze_account_request.rb,
lib/unit/models/account/credit/balance_history_request.rb

Defined Under Namespace

Classes: BalanceHistoryRequest, CloseAccountRequest, CreateAccountRequest, FreezeAccountRequest, ListAccountParams, PatchAccountRequest

Constant Summary collapse

ACCOUNT_LIST_LIMIT =
100
ACCOUNT_LIST_OFFSET =
0
BALANCE_HISTORY_LIMIT =
100
BALANCE_HISTORY_OFFSET =
0

Class Method Summary collapse

Class Method Details

.close_credit_account(account_id:, reason:, fraud_reason: nil) ⇒ Object

Close a credit account

Parameters:

  • account_id (String)
  • reason (String)
  • fraud_reason (String) (defaults to: nil)
    • optional

See Also:



187
188
189
190
# File 'lib/unit/models/account/account.rb', line 187

def (account_id:, reason:, fraud_reason: nil)
  request = CloseAccountRequest.new(, reason, fraud_reason)
  Unit::Resource::AccountResource.(request)
end

.create_credit_account(credit_terms:, credit_limit:, customer_id: nil, tags: nil, idempotency_key: nil) ⇒ Object

Create a credit account

Parameters:

  • credit_terms (String)
  • credit_limit (Integer)
  • customer_id (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • idempotency_key (String) (defaults to: nil)
    • optional

See Also:



177
178
179
180
# File 'lib/unit/models/account/account.rb', line 177

def (credit_terms:, credit_limit:, customer_id: nil, tags: nil, idempotency_key: nil)
  request = CreateAccountRequest.new(credit_terms, credit_limit, customer_id, tags, idempotency_key)
  Unit::Resource::AccountResource.(request)
end

.freeze_credit_account(account_id:, reason:, reason_text: nil) ⇒ Object

Freeze credit account

Parameters:

  • account_id (String)
  • reason (String)
  • reason_text (String) (defaults to: nil)
    • optional

See Also:



204
205
206
207
# File 'lib/unit/models/account/account.rb', line 204

def (account_id:, reason:, reason_text: nil)
  request = FreezeAccountRequest.new(, reason, reason_text)
  Unit::Resource::AccountResource.(request)
end

.get_balance_history(limit = BALANCE_HISTORY_LIMIT, offset = BALANCE_HISTORY_OFFSET, account_id: nil, customer_id: nil, since: nil, _until: nil) ⇒ Object

Get account balance history by calling Unit’s API

Parameters:

  • limit (Integer) (defaults to: BALANCE_HISTORY_LIMIT)
    • optional

  • offset (Integer) (defaults to: BALANCE_HISTORY_OFFSET)
    • optional

  • account_id (String) (defaults to: nil)
    • optional

  • customer_id (String) (defaults to: nil)
    • optional

  • since (String) (defaults to: nil)
    • optional

  • _until (String) (defaults to: nil)
    • optional

See Also:



257
258
259
260
261
# File 'lib/unit/models/account/account.rb', line 257

def get_balance_history(limit = BALANCE_HISTORY_LIMIT, offset = BALANCE_HISTORY_OFFSET, account_id: nil, customer_id: nil,
                        since: nil, _until: nil)
  request = BalanceHistoryRequest.new(limit, offset, , customer_id, since, _until)
  Unit::Resource::AccountResource.(request)
end

.get_credit_account(account_id:) ⇒ Object

Get a credit account by id

Parameters:

  • account_id (String)

See Also:



195
196
197
# File 'lib/unit/models/account/account.rb', line 195

def (account_id:)
  Unit::Resource::AccountResource.()
end

.limits(account_id:) ⇒ Object

Limit a credit account

Parameters:

  • account_id (String)

See Also:



245
246
247
# File 'lib/unit/models/account/account.rb', line 245

def limits(account_id:)
  Unit::Resource::AccountResource.limits()
end

.list_credit_accounts(limit: ACCOUNT_LIST_LIMIT, offset: ACCOUNT_LIST_OFFSET, customer_id: nil, tags: nil, status: nil, from_balance: nil, to_balance: nil, include: nil, type: nil) ⇒ Object

List credit accounts by calling Unit’s API

Parameters:

  • limit (Integer) (defaults to: ACCOUNT_LIST_LIMIT)
    • optional

  • offset (Integer) (defaults to: ACCOUNT_LIST_OFFSET)
    • optional

  • customer_id (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • status (Array<String>) (defaults to: nil)
    • optional

  • from_balance (Integer) (defaults to: nil)
    • optional

  • to_balance (Integer) (defaults to: nil)
    • optional

  • include (Array) (defaults to: nil)
    • optional

  • type (String) (defaults to: nil)
    • optional

See Also:



227
228
229
230
231
# File 'lib/unit/models/account/account.rb', line 227

def list_credit_accounts(limit: ACCOUNT_LIST_LIMIT, offset: ACCOUNT_LIST_OFFSET, customer_id: nil, tags: nil,
                         status: nil, from_balance: nil, to_balance: nil, include: nil, type: nil)
  request = ListAccountParams.new(limit, offset, customer_id, tags, status, from_balance, to_balance, include, type)
  Unit::Resource::AccountResource.list_accounts(request)
end

.unfreeze_credit_account(account_id:) ⇒ Object

Unfreeze credit account

Parameters:

  • account_id (String)

See Also:



212
213
214
# File 'lib/unit/models/account/account.rb', line 212

def (account_id:)
  Unit::Resource::AccountResource.()
end

.update_credit_account(account_id:, tags: nil, credit_limit: nil) ⇒ Object

Update a credit account by calling Unit’s API

Parameters:

  • tags (Hash) (defaults to: nil)
    • optional

  • credit_limit (Integer) (defaults to: nil)
    • optional

See Also:



237
238
239
240
# File 'lib/unit/models/account/account.rb', line 237

def (account_id:, tags: nil, credit_limit: nil)
  request = PatchAccountRequest.new(, tags, credit_limit)
  Unit::Resource::AccountResource.(request)
end