/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Account } from '../models/Account';
import type { AccountBalance } from '../models/AccountBalance';
import type { Blockage } from '../models/Blockage';
import type { BlockAmount } from '../models/BlockAmount';
import type { CreateAccount } from '../models/CreateAccount';
import type { CreateAccountBatch } from '../models/CreateAccountBatch';
import type { CreateAccountXpub } from '../models/CreateAccountXpub';
import type { EntitiesCount } from '../models/EntitiesCount';
import type { Id } from '../models/Id';
import type { TransactionResult } from '../models/TransactionResult';
import type { UnblockAmount } from '../models/UnblockAmount';
import type { UpdateAccount } from '../models/UpdateAccount';
import type { CancelablePromise } from '../core/CancelablePromise';
import { request as __request } from '../core/request';
export class AccountService {
/**
* Create a virtual account
*
2 credits per API call
* Create a new virtual account for a customer.
*
* - If the customer that you specified in the request body already exists, the newly created virtual account is added to this customer's list of accounts.
* - If the customer that you specified in the request body does not exist yet, a new customer is created together with the virtual account, and the virtual account is added to this customer.
*
* You can create a virtual account for any supported cryptocurrency, fiat currency, Tatum virtual currency, or fungible tokens created within Tatum. Once the currency/asset is set for a virtual account, it cannot be changed.
* Virtual account balance
* A virtual account has its own balance. The balance can be logically presented by the account balance and available balance:
*
* - The account balance (
accountBalance) represents all assets on the account, both available and blocked.
* - The available balance (
availableBalance) represents the account balance minus the blocked assets. Use the available balance to determine how much a customer can send or withdraw from their virtual account.
*
* Cryptocurrency virtual accounts
* When you create a virtual account based on a cryptocurrency (for example, BTC or ETH), you have to provide the extended public key (xpub) of the blockchain wallet that will be connected to this account.
* NOTE: Adding xpub to the virtual account does not connect any specific blockchain address to this account. xpub is a generator of addresses, not an address itself.
* Not all blockchains provide xpub for wallets, or Tatum may not support wallets on some blockchains. In such cases, use the wallet address or the account address instead.
*
* Connect a virtual account to the blockchain
*
* You can connect multiple blockchain addresses to one virtual account.
*
* @param requestBody
* @returns Account OK
* @throws ApiError
*/
public static createAccount(
requestBody: (CreateAccountXpub | CreateAccount),
): CancelablePromise {
return __request({
method: 'POST',
path: `/v3/ledger/account`,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* List all accounts
* 1 credit per API call.
Lists all accounts. Inactive accounts are also visible.
* @param pageSize Max number of items per page is 50.
* @param page Page number
* @param sort Direction of sorting. Can be asc or desc
* @param sortBy Sort by
* @param active Filter only active or non active accounts
* @param onlyNonZeroBalance Filter only accounts with non zero balances
* @param frozen Filter only frozen or non frozen accounts
* @param currency Filter by currency
* @param accountNumber Filter by account number
* @returns Account OK
* @throws ApiError
*/
public static getAccounts(
pageSize?: number,
page?: number,
sort?: 'asc' | 'desc',
sortBy?: '_id' | 'account_number' | 'account_balance' | 'available_balance',
active?: boolean,
onlyNonZeroBalance?: boolean,
frozen?: boolean,
currency?: string,
accountNumber?: string,
): CancelablePromise> {
return __request({
method: 'GET',
path: `/v3/ledger/account`,
query: {
'pageSize': pageSize,
'page': page,
'sort': sort,
'sortBy': sortBy,
'active': active,
'onlyNonZeroBalance': onlyNonZeroBalance,
'frozen': frozen,
'currency': currency,
'accountNumber': accountNumber,
},
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Count of found entities for get accounts request
* 1 credit per API call.
Count of accounts that were found from /v3/ledger/account
* @param pageSize Max number of items per page is 50.
* @param page Page number
* @param sort Direction of sorting. Can be asc or desc
* @param sortBy Sort by
* @param active Filter only active or non active accounts
* @param onlyNonZeroBalance Filter only accounts with non zero balances
* @param frozen Filter only frozen or non frozen accounts
* @param currency Filter by currency
* @param accountNumber Filter by account number
* @returns EntitiesCount OK
* @throws ApiError
*/
public static getAccountsCount(
pageSize?: number,
page?: number,
sort?: 'asc' | 'desc',
sortBy?: '_id' | 'account_number' | 'account_balance' | 'available_balance',
active?: boolean,
onlyNonZeroBalance?: boolean,
frozen?: boolean,
currency?: string,
accountNumber?: string,
): CancelablePromise {
return __request({
method: 'GET',
path: `/v3/ledger/account/count`,
query: {
'pageSize': pageSize,
'page': page,
'sort': sort,
'sortBy': sortBy,
'active': active,
'onlyNonZeroBalance': onlyNonZeroBalance,
'frozen': frozen,
'currency': currency,
'accountNumber': accountNumber,
},
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Create multiple accounts in a batch call
* 2 credits per API call + 1 credit for every account created.
* Creates new accounts for the customer in a batch call.
*
* @param requestBody
* @returns Account OK
* @throws ApiError
*/
public static createAccountBatch(
requestBody: CreateAccountBatch,
): CancelablePromise> {
return __request({
method: 'POST',
path: `/v3/ledger/account/batch`,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* List all customer accounts
* 1 credit per API call.
Lists all accounts associated with a customer. Only active accounts are visible.
* @param pageSize Max number of items per page is 50.
* @param id Internal customer ID
* @param offset Offset to obtain the next page of data.
* @param accountCode For bookkeeping to distinct account purpose.
* @returns Account OK
* @throws ApiError
*/
public static getAccountsByCustomerId(
pageSize: number,
id: string,
offset?: number,
accountCode?: string,
): CancelablePromise> {
return __request({
method: 'GET',
path: `/v3/ledger/account/customer/${id}`,
query: {
'pageSize': pageSize,
'offset': offset,
'accountCode': accountCode,
},
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Get account by ID
* 1 credit per API call.
Gets active account by ID. Displays all information regarding the given account.
* @param id Account ID
* @returns Account OK
* @throws ApiError
*/
public static getAccountByAccountId(
id: string,
): CancelablePromise {
return __request({
method: 'GET',
path: `/v3/ledger/account/${id}`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Update account
* 2 credits per API call.
Update account by ID. Only a small number of fields can be updated.
* @param id Account ID
* @param requestBody
* @returns void
* @throws ApiError
*/
public static updateAccountByAccountId(
id: string,
requestBody: UpdateAccount,
): CancelablePromise {
return __request({
method: 'PUT',
path: `/v3/ledger/account/${id}`,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Get account balance
* 1 credit per API call.
Get balance for the account.
* @param id Account ID
* @returns AccountBalance OK
* @throws ApiError
*/
public static getAccountBalance(
id: string,
): CancelablePromise {
return __request({
method: 'GET',
path: `/v3/ledger/account/${id}/balance`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Block an amount in an account
* 2 credits per API call.
* Blocks an amount in an account. Any number of distinct amounts can be blocked in one account.
* Every new blockage has its own distinct ID, which is used as a reference. When the amount is blocked, it is debited from the available balance of the account.
* The account balance remains the same. The account balance represents the total amount of funds in the account. The available balance represents the total amount of funds that can be used to perform transactions. When an account is frozen, the available balance is set to 0 minus all blockages for the account.
*
* @param id Account ID
* @param requestBody
* @returns Id OK
* @throws ApiError
*/
public static blockAmount(
id: string,
requestBody: BlockAmount,
): CancelablePromise {
return __request({
method: 'POST',
path: `/v3/ledger/account/block/${id}`,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Unblock an amount in an account and perform a transaction
* 2 credits per API call.
* Unblocks a previously blocked amount in an account and invokes a ledger transaction from that account to a different recipient.
* If the request fails, the amount is not unblocked.
*
* @param id Blockage ID
* @param requestBody
* @returns TransactionResult OK
* @throws ApiError
*/
public static unblockAmountWithTransaction(
id: string,
requestBody: UnblockAmount,
): CancelablePromise {
return __request({
method: 'PUT',
path: `/v3/ledger/account/block/${id}`,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Unblock a blocked amount in an account
* 1 credit per API call.
Unblocks a previously blocked amount in an account. Increases the available balance in the account where the amount was blocked.
* @param id Blockage ID
* @returns void
* @throws ApiError
*/
public static deleteBlockAmount(
id: string,
): CancelablePromise {
return __request({
method: 'DELETE',
path: `/v3/ledger/account/block/${id}`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Get blocked amounts in an account
* 1 credit per API call.
Gets blocked amounts for an account.
* @param id Account ID
* @param pageSize Max number of items per page is 50.
* @param offset Offset to obtain the next page of data.
* @returns Blockage OK
* @throws ApiError
*/
public static getBlockAmount(
id: string,
pageSize: number,
offset?: number,
): CancelablePromise> {
return __request({
method: 'GET',
path: `/v3/ledger/account/block/${id}`,
query: {
'pageSize': pageSize,
'offset': offset,
},
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Get blocked amount by ID
* 1 credit per API call.
Gets blocked amount by id.
* @param id Blocked amount ID
* @returns Blockage OK
* @throws ApiError
*/
public static getBlockAmountById(
id: string,
): CancelablePromise {
return __request({
method: 'GET',
path: `/v3/ledger/account/block/${id}/detail`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Unblock all blocked amounts in an account
* 1 credit per API call, 1 credit for each deleted blockage. 1 API call + 2 blockages = 3 credits.
Unblocks previously blocked amounts in an account. Increases the available balance in the account where the amount was blocked.
* @param id Account ID
* @returns void
* @throws ApiError
*/
public static deleteAllBlockAmount(
id: string,
): CancelablePromise {
return __request({
method: 'DELETE',
path: `/v3/ledger/account/block/account/${id}`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Activate account
* 2 credits per API call.
Activates an account.
* @param id Account ID
* @returns void
* @throws ApiError
*/
public static activateAccount(
id: string,
): CancelablePromise {
return __request({
method: 'PUT',
path: `/v3/ledger/account/${id}/activate`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due a to logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Deactivate account
* 2 credits per API call.
Deactivates an account. Only accounts with account and available balances of zero can be deactivated. Deactivated accounts are not visible in the list of accounts, it is not possible to send funds to these accounts or perform transactions. However, they are still present in the ledger and all transaction histories.
* @param id Account ID
* @returns void
* @throws ApiError
*/
public static deactivateAccount(
id: string,
): CancelablePromise {
return __request({
method: 'PUT',
path: `/v3/ledger/account/${id}/deactivate`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Freeze account
* 2 credits per API call.
Disables all outgoing transactions. Incoming transactions to the account are available. When an account is frozen, its available balance is set to 0. This operation will create a new blockage of type ACCOUNT_FROZEN, which is automatically deleted when the account is unfrozen.
* @param id Account ID
* @returns void
* @throws ApiError
*/
public static freezeAccount(
id: string,
): CancelablePromise {
return __request({
method: 'PUT',
path: `/v3/ledger/account/${id}/freeze`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
/**
* Unfreeze account
* 2 credits per API call.
Unfreezes a previously frozen account. Unfreezing a non-frozen account not affect the account.
* @param id Account ID
* @returns void
* @throws ApiError
*/
public static unfreezeAccount(
id: string,
): CancelablePromise {
return __request({
method: 'PUT',
path: `/v3/ledger/account/${id}/unfreeze`,
errors: {
400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`,
401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`,
403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`,
500: `Internal server error. There was an error on the server while processing the request.`,
},
});
}
}