From 8c337ec244ca5f691fe68ed01d17b3be71761699 Mon Sep 17 00:00:00 2001 From: Shir Gerasi Date: Thu, 2 Dec 2021 15:09:24 +0200 Subject: [PATCH] Add RequestOptions for all post request --- src/fireblocks-sdk.ts | 128 +++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index a7e719c5..5b2110cb 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -140,11 +140,11 @@ export class FireblocksSDK { * @param description A description for the new address * @param customerRefId A customer reference ID */ - public async generateNewAddress(vaultAccountId: string, assetId: string, description?: string, customerRefId?: string): Promise { + public async generateNewAddress(vaultAccountId: string, assetId: string, description?: string, customerRefId?: string, requestOptions?: RequestOptions): Promise { return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses`, { description, customerRefId - }); + }, requestOptions); } /** @@ -211,13 +211,13 @@ export class FireblocksSDK { * @param assetId The asset to transfer * @param amount The amount to transfer */ - public async transferToSubaccount(exchangeAccountId: string, subaccountId: string, assetId: string, amount: number): Promise { + public async transferToSubaccount(exchangeAccountId: string, subaccountId: string, assetId: string, amount: number, requestOptions?: RequestOptions): Promise { const body = { subaccountId, amount }; - return await this.apiClient.issuePostRequest(`/v1/exchange_accounts/${exchangeAccountId}/${assetId}/transfer_to_subaccount`, body); + return await this.apiClient.issuePostRequest(`/v1/exchange_accounts/${exchangeAccountId}/${assetId}/transfer_to_subaccount`, body, requestOptions); } /** @@ -227,13 +227,13 @@ export class FireblocksSDK { * @param assetId The asset to transfer * @param amount The amount to transfer */ - public async transferFromSubaccount(exchangeAccountId: string, subaccountId: string, assetId: string, amount: number): Promise { + public async transferFromSubaccount(exchangeAccountId: string, subaccountId: string, assetId: string, amount: number, requestOptions?: RequestOptions): Promise { const body = { subaccountId, amount }; - return await this.apiClient.issuePostRequest(`/v1/exchange_accounts/${exchangeAccountId}/${assetId}/transfer_from_subaccount`, body); + return await this.apiClient.issuePostRequest(`/v1/exchange_accounts/${exchangeAccountId}/${assetId}/transfer_from_subaccount`, body, requestOptions); } /** @@ -256,12 +256,12 @@ export class FireblocksSDK { * @param accountId The fiat account ID in Fireblocks * @param amount The amount to transfer */ - public async redeemToLinkedDDA(accountId: string, amount: number): Promise { + public async redeemToLinkedDDA(accountId: string, amount: number, requestOptions?: RequestOptions): Promise { const body = { amount }; - return await this.apiClient.issuePostRequest(`/v1/fiat_accounts/${accountId}/redeem_to_linked_dda`, body); + return await this.apiClient.issuePostRequest(`/v1/fiat_accounts/${accountId}/redeem_to_linked_dda`, body, requestOptions); } /** @@ -269,12 +269,12 @@ export class FireblocksSDK { * @param accountId The fiat account ID in Fireblocks * @param amount The amount to transfer */ - public async depositFromLinkedDDA(accountId: string, amount: number): Promise { + public async depositFromLinkedDDA(accountId: string, amount: number, requestOptions?: RequestOptions): Promise { const body = { amount }; - return await this.apiClient.issuePostRequest(`/v1/fiat_accounts/${accountId}/deposit_from_linked_dda`, body); + return await this.apiClient.issuePostRequest(`/v1/fiat_accounts/${accountId}/deposit_from_linked_dda`, body, requestOptions); } /** @@ -374,8 +374,8 @@ export class FireblocksSDK { * Cancels the selected transaction * @param txId The transaction id to cancel */ - public async cancelTransactionById(txId: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/transactions/${txId}/cancel`, {}); + public async cancelTransactionById(txId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/transactions/${txId}/cancel`, {}, requestOptions); } /** @@ -384,7 +384,7 @@ export class FireblocksSDK { * @param hiddenOnUI If true, the created account and all related transactions will not be shown on Fireblocks console * @param customerRefId A customer reference ID */ - public async createVaultAccount(name: string, hiddenOnUI?: boolean, customerRefId?: string, autoFuel?: boolean): Promise { + public async createVaultAccount(name: string, hiddenOnUI?: boolean, customerRefId?: string, autoFuel?: boolean, requestOptions?: RequestOptions): Promise { const body = { name, customerRefId, @@ -392,23 +392,23 @@ export class FireblocksSDK { autoFuel: autoFuel || false }; - return await this.apiClient.issuePostRequest("/v1/vault/accounts", body); + return await this.apiClient.issuePostRequest("/v1/vault/accounts", body, requestOptions); } /** * Hides a vault account in Fireblocks console * @param vaultAccountId The vault account ID */ - public async hideVaultAccount(vaultAccountId: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/hide`, {}); + public async hideVaultAccount(vaultAccountId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/hide`, {}, requestOptions); } /** * Reveals a hidden vault account in Fireblocks console * @param vaultAccountId The vault account ID */ - public async unhideVaultAccount(vaultAccountId: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/unhide`, {}); + public async unhideVaultAccount(vaultAccountId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/unhide`, {}, requestOptions); } /** @@ -416,8 +416,8 @@ export class FireblocksSDK { * @param vaultAccountId The vault account ID * @param autoFuel The new value for the autoFuel flag */ - public async setAutoFuel(vaultAccountId: string, autoFuel: boolean): Promise { - return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_auto_fuel`, {autoFuel}); + public async setAutoFuel(vaultAccountId: string, autoFuel: boolean, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_auto_fuel`, {autoFuel}, requestOptions); } /** @@ -437,8 +437,8 @@ export class FireblocksSDK { * @param vaultAccountId The vault account ID * @param assetId The asset to add */ - public async createVaultAsset(vaultAccountId: string, assetId: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}`, {}); + public async createVaultAsset(vaultAccountId: string, assetId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}`, {}, requestOptions); } /** @@ -446,13 +446,13 @@ export class FireblocksSDK { * @param name A name for the new external wallet * @param customerRefId A customer reference ID */ - public async createExternalWallet(name: string, customerRefId?: string): Promise> { + public async createExternalWallet(name: string, customerRefId?: string, requestOptions?: RequestOptions): Promise> { const body = { name, customerRefId }; - return await this.apiClient.issuePostRequest("/v1/external_wallets", body); + return await this.apiClient.issuePostRequest("/v1/external_wallets", body, requestOptions); } /** @@ -460,13 +460,13 @@ export class FireblocksSDK { * @param name A name for the new internal wallet * @param customerRefId A customer reference ID */ - public async createInternalWallet(name: string, customerRefId?: string): Promise> { + public async createInternalWallet(name: string, customerRefId?: string, requestOptions?: RequestOptions): Promise> { const body = { name, customerRefId }; - return await this.apiClient.issuePostRequest("/v1/internal_wallets", body); + return await this.apiClient.issuePostRequest("/v1/internal_wallets", body, requestOptions); } /** @@ -476,14 +476,14 @@ export class FireblocksSDK { * @param address The wallet address * @param tag (for ripple only) The ripple account tag */ - public async createExternalWalletAsset(walletId: string, assetId: string, address: string, tag?: string): Promise { + public async createExternalWalletAsset(walletId: string, assetId: string, address: string, tag?: string, requestOptions?: RequestOptions): Promise { const path = `/v1/external_wallets/${walletId}/${assetId}`; const body = { address: address, tag: tag }; - return await this.apiClient.issuePostRequest(path, body); + return await this.apiClient.issuePostRequest(path, body, requestOptions); } /** @@ -493,14 +493,14 @@ export class FireblocksSDK { * @param address The wallet address * @param tag (for ripple only) The ripple account tag */ - public async createInternalWalletAsset(walletId: string, assetId: string, address: string, tag?: string): Promise { + public async createInternalWalletAsset(walletId: string, assetId: string, address: string, tag?: string, requestOptions?: RequestOptions): Promise { const path = `/v1/internal_wallets/${walletId}/${assetId}`; const body = { address: address, tag: tag }; - return await this.apiClient.issuePostRequest(path, body); + return await this.apiClient.issuePostRequest(path, body, requestOptions); } /** @@ -513,8 +513,8 @@ export class FireblocksSDK { /** * Estimates the fee for a transaction request */ - public async estimateFeeForTransaction(transactionArguments: TransactionArguments): Promise { - return await this.apiClient.issuePostRequest("/v1/transactions/estimate_fee", transactionArguments); + public async estimateFeeForTransaction(transactionArguments: TransactionArguments, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest("/v1/transactions/estimate_fee", transactionArguments, requestOptions); } /** @@ -527,8 +527,8 @@ export class FireblocksSDK { /** * Creates a new transfer ticket */ - public async createTransferTicket(options: CreateTransferTicketArgs): Promise { - return await this.apiClient.issuePostRequest("/v1/transfer_tickets", options); + public async createTransferTicket(options: CreateTransferTicketArgs, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest("/v1/transfer_tickets", options, requestOptions); } /** @@ -559,8 +559,8 @@ export class FireblocksSDK { * Cancel the transfer ticket * @param ticketId */ - public async cancelTransferTicket(ticketId: string) { - return await this.apiClient.issuePostRequest(`/v1/transfer_tickets/${ticketId}/cancel`, {}); + public async cancelTransferTicket(ticketId: string, requestOptions?: RequestOptions) { + return await this.apiClient.issuePostRequest(`/v1/transfer_tickets/${ticketId}/cancel`, {}, requestOptions); } /** @@ -569,9 +569,9 @@ export class FireblocksSDK { * @param termId * @param options */ - public async executeTransferTicketTerm(ticketId: string, termId: string, options: ExecuteTermArgs) { + public async executeTransferTicketTerm(ticketId: string, termId: string, options: ExecuteTermArgs, requestOptions?: RequestOptions) { return await this.apiClient.issuePostRequest(`/v1/transfer_tickets/${ticketId}/${termId}/transfer`, - options); + options, requestOptions); } /** @@ -613,8 +613,8 @@ export class FireblocksSDK { * @param vaultAccountId The vault account ID * @param customerRefId The customer reference ID to set */ - public async setCustomerRefIdForVaultAccount(vaultAccountId: string, customerRefId: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_customer_ref_id`, {customerRefId}); + public async setCustomerRefIdForVaultAccount(vaultAccountId: string, customerRefId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_customer_ref_id`, {customerRefId}, requestOptions); } /** @@ -622,8 +622,8 @@ export class FireblocksSDK { * @param walletId The ID of the internal wallet * @param customerRefId The customer reference ID to set */ - public async setCustomerRefIdForInternalWallet(walletId: string, customerRefId: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/internal_wallets/${walletId}/set_customer_ref_id`, {customerRefId}); + public async setCustomerRefIdForInternalWallet(walletId: string, customerRefId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/internal_wallets/${walletId}/set_customer_ref_id`, {customerRefId}, requestOptions); } /** @@ -631,8 +631,8 @@ export class FireblocksSDK { * @param walletId The ID of the external wallet * @param customerRefId The customer reference ID to set */ - public async setCustomerRefIdForExternalWallet(walletId: string, customerRefId: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/external_wallets/${walletId}/set_customer_ref_id`, {customerRefId}); + public async setCustomerRefIdForExternalWallet(walletId: string, customerRefId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/external_wallets/${walletId}/set_customer_ref_id`, {customerRefId}, requestOptions); } /** @@ -643,13 +643,13 @@ export class FireblocksSDK { * @param tag The XRP tag, or EOS memo * @param customerRefId The customer reference ID to set */ - public async setCustomerRefIdForAddress(vaultAccountId: string, assetId: string, address: string, tag?: string, customerRefId?: string): Promise { + public async setCustomerRefIdForAddress(vaultAccountId: string, assetId: string, address: string, tag?: string, customerRefId?: string, requestOptions?: RequestOptions): Promise { let addressId = address; if (tag && tag.length > 0) { addressId = `${address}:${tag}`; } - return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses/${addressId}/set_customer_ref_id`, {customerRefId}); + return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses/${addressId}/set_customer_ref_id`, {customerRefId}, requestOptions); } /** @@ -657,8 +657,8 @@ export class FireblocksSDK { * @param txId * @param requiredConfirmationsNumber */ - public async setConfirmationThresholdForTxId(txId: string, requiredConfirmationsNumber: number): Promise { - return await this.apiClient.issuePostRequest(`/v1/transactions/${txId}/set_confirmation_threshold`, {numOfConfirmations: requiredConfirmationsNumber}); + public async setConfirmationThresholdForTxId(txId: string, requiredConfirmationsNumber: number, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/transactions/${txId}/set_confirmation_threshold`, {numOfConfirmations: requiredConfirmationsNumber}, requestOptions); } /** @@ -666,8 +666,8 @@ export class FireblocksSDK { * @param txHash * @param requiredConfirmationsNumber */ - public async setConfirmationThresholdForTxHash(txHash: string, requiredConfirmationsNumber: number): Promise { - return await this.apiClient.issuePostRequest(`/v1/txHash/${txHash}/set_confirmation_threshold`, {numOfConfirmations: requiredConfirmationsNumber}); + public async setConfirmationThresholdForTxHash(txHash: string, requiredConfirmationsNumber: number, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/txHash/${txHash}/set_confirmation_threshold`, {numOfConfirmations: requiredConfirmationsNumber}, requestOptions); } /** @@ -696,9 +696,9 @@ export class FireblocksSDK { * @param asset * @param args */ - public async allocateFundsToPrivateLedger(vaultAccountId: string, asset: string, args: AllocateFundsRequest) { + public async allocateFundsToPrivateLedger(vaultAccountId: string, asset: string, args: AllocateFundsRequest, requestOptions?: RequestOptions) { const url = `/v1/vault/accounts/${vaultAccountId}/${asset}/lock_allocation`; - return await this.apiClient.issuePostRequest(url, args); + return await this.apiClient.issuePostRequest(url, args, requestOptions); } /** @@ -707,9 +707,9 @@ export class FireblocksSDK { * @param asset * @param args */ - public async deallocateFundsFromPrivateLedger(vaultAccountId: string, asset: string, args: DeallocateFundsRequest) { + public async deallocateFundsFromPrivateLedger(vaultAccountId: string, asset: string, args: DeallocateFundsRequest, requestOptions?: RequestOptions) { const url = `/v1/vault/accounts/${vaultAccountId}/${asset}/release_allocation`; - return await this.apiClient.issuePostRequest(url, args); + return await this.apiClient.issuePostRequest(url, args, requestOptions); } /** @@ -747,12 +747,12 @@ export class FireblocksSDK { /** * Drop an ETH based transaction */ - public async dropTransaction(txId: string, feeLevel?: string, requestedFee?: string) { + public async dropTransaction(txId: string, feeLevel?: string, requestedFee?: string, requestOptions?: RequestOptions) { const url = `/v1/transactions/${txId}/drop`; const body = {feeLevel, requestedFee}; - return await this.apiClient.issuePostRequest(url, body); + return await this.apiClient.issuePostRequest(url, body, requestOptions); } /** @@ -797,23 +797,23 @@ export class FireblocksSDK { * Unfreezes the selected transaction * @param txId The transaction id to unfreeze */ - public async unfreezeTransactionById(txId: string): Promise { - return this.apiClient.issuePostRequest(`/v1/transactions/${txId}/unfreeze`, {}); + public async unfreezeTransactionById(txId: string, requestOptions?: RequestOptions): Promise { + return this.apiClient.issuePostRequest(`/v1/transactions/${txId}/unfreeze`, {}, requestOptions); } /** * Freezes the selected transaction * @param txId The transaction id to freeze */ - public async freezeTransactionById(txId: string): Promise { - return this.apiClient.issuePostRequest(`/v1/transactions/${txId}/freeze`, {}); + public async freezeTransactionById(txId: string, requestOptions?: RequestOptions): Promise { + return this.apiClient.issuePostRequest(`/v1/transactions/${txId}/freeze`, {}, requestOptions); } /** * Resend failed webhooks */ - public async resendWebhooks(): Promise { - return await this.apiClient.issuePostRequest("/v1/webhooks/resend", {}); + public async resendWebhooks(requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest("/v1/webhooks/resend", {}, requestOptions); } /** @@ -842,7 +842,7 @@ export class FireblocksSDK { * Settle off exchange account by virtual account id * @param id the ID of the off exchange */ - public async settleOffExchangeAccountById(id: string): Promise { - return await this.apiClient.issuePostRequest(`/v1/off_exchange_accounts/${id}/settle`, {}); + public async settleOffExchangeAccountById(id: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issuePostRequest(`/v1/off_exchange_accounts/${id}/settle`, {}, requestOptions); } }