/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { Account } from '../models/Account'; import type { CreateSubscriptionBalance } from '../models/CreateSubscriptionBalance'; import type { CreateSubscriptionContractLogEvent } from '../models/CreateSubscriptionContractLogEvent'; import type { CreateSubscriptionIncoming } from '../models/CreateSubscriptionIncoming'; import type { CreateSubscriptionInterval } from '../models/CreateSubscriptionInterval'; import type { CreateSubscriptionKMSError } from '../models/CreateSubscriptionKMSError'; import type { CreateSubscriptionKMSSuccess } from '../models/CreateSubscriptionKMSSuccess'; import type { CreateSubscriptionMultiTokenTransferEvent } from '../models/CreateSubscriptionMultiTokenTransferEvent'; import type { CreateSubscriptionNftTransferEvent } from '../models/CreateSubscriptionNftTransferEvent'; import type { CreateSubscriptionNotification } from '../models/CreateSubscriptionNotification'; import type { CreateSubscriptionPartialTradeMatch } from '../models/CreateSubscriptionPartialTradeMatch'; import type { CreateSubscriptionPending } from '../models/CreateSubscriptionPending'; import type { CreateSubscriptionTradeMatch } from '../models/CreateSubscriptionTradeMatch'; import type { CreateSubscriptionTxInTheBlock } from '../models/CreateSubscriptionTxInTheBlock'; import type { EntitiesCount } from '../models/EntitiesCount'; import type { HmacWebHook } from '../models/HmacWebHook'; import type { Id } from '../models/Id'; import type { Subscription } from '../models/Subscription'; import type { Transaction } from '../models/Transaction'; import type { WebHook } from '../models/WebHook'; import type { CancelablePromise } from '../core/CancelablePromise'; import { request as __request } from '../core/request'; export class NotificationSubscriptionsService { /** * Create a subscription *

2 credits per API call + credits spent on subscriptions themselves
* Each subscription type consumes a different number of credits.

*

For Free plans, there is a monthly limit of sent webhooks, which is 1000.

*

If the webhook is sent unsuccessfully, it will be retried. The number of retries depends on the plan.

* *

Create a subscription as an HTTP web hook.

*

The following subscription types are available:

* * In case of unsuccesful web hook response status - other then 2xx - web hook is repeated 9 more times with exponential backoff. * Parameters are T = 15 * 2.7925^9, where 15 is interval in s, backoff rate is 2.7925 and 9 is current number of retries. Last web hook is fired after 24 hours approximatelly. After last failed attempt, web hook is deleted from our system. The 2xx response must be returned in 10 seconds after web hook is fired.
* Result of the operation is subscription ID, which can be used to cancel subscription or obtain additional data connected to it like reports.

* * @param requestBody * @param testnetType Type of Ethereum testnet. Defaults to ethereum-sepolia. * @returns Id OK * @throws ApiError */ public static createSubscription( requestBody: (CreateSubscriptionNotification | CreateSubscriptionNftTransferEvent | CreateSubscriptionMultiTokenTransferEvent | CreateSubscriptionContractLogEvent | CreateSubscriptionIncoming | CreateSubscriptionPending | CreateSubscriptionTradeMatch | CreateSubscriptionPartialTradeMatch | CreateSubscriptionKMSError | CreateSubscriptionKMSSuccess | CreateSubscriptionTxInTheBlock | CreateSubscriptionBalance | CreateSubscriptionInterval), testnetType: 'ethereum-sepolia' | 'ethereum-goerli' = 'ethereum-sepolia', ): CancelablePromise { return __request({ method: 'POST', path: `/v3/subscription`, query: { 'testnetType': testnetType, }, 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 required perform operation due to logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server while processing the request.`, }, }); } /** * List all active subscriptions *

1 credit per API call.


List all active subscriptions.

* @param pageSize Max number of items per page is 50. * @param offset Offset to obtain next page of the data. * @param address Value for filtering by address * @returns Subscription OK * @throws ApiError */ public static getSubscriptions( pageSize: number, offset?: number, address?: string, ): CancelablePromise> { return __request({ method: 'GET', path: `/v3/subscription`, query: { 'pageSize': pageSize, 'offset': offset, 'address': address, }, 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.`, }, }); } /** * Enable HMAC webhook digest *

2 credits per API call.


Enable HMAC hash ID on the fired webhooks from Tatum API. * In order to make sure that a webhook is sent by us, we have the possibility to sign it with the HMAC Sha512 Hex algorithm.
* To verify that a webhook is sent by us *

    *
  1. Get a webhook x-payload-hash header value and payload as it is as a JSON file.
  2. *
  3. Convert the HTTP webhook body to stringify JSON without any spaces. In JavaScript, you would do it like this
    JSON.stringify(req.body)
  4. *
  5. Perform calculations on your side to create a digest using Secret Key, webhook payload in bytes and HMAC SHA512 algorithm. JavaScript example: *
    require('crypto').createHmac('sha512', hmacSecret).update(JSON.stringify(req.body)).digest('base64')
    .
  6. *
  7. Compare x-payload-hash header value with calculated digest as a Base64 string.
  8. * * @param requestBody * @returns void * @throws ApiError */ public static enableWebHookHmac( requestBody: HmacWebHook, ): CancelablePromise { return __request({ method: 'PUT', path: `/v3/subscription`, body: requestBody, mediaType: 'application/json', errors: { 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.`, }, }); } /** * Disable HMAC webhook digest *

    2 credits per API call.


    Disable HMAC hash ID on the fired webhooks from Tatum API.

    * * @returns void * @throws ApiError */ public static disableWebHookHmac(): CancelablePromise { return __request({ method: 'DELETE', path: `/v3/subscription`, errors: { 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 webhook request *

    1 credit per API call.


    Count of subscriptions that were found from /v3/subscription

    * @param pageSize Max number of items per page is 50. * @param offset Offset to obtain next page of the data. * @param address Value for filtering by address * @returns EntitiesCount OK * @throws ApiError */ public static getSubscriptionsCount( pageSize: number, offset?: number, address?: string, ): CancelablePromise { return __request({ method: 'GET', path: `/v3/subscription/count`, query: { 'pageSize': pageSize, 'offset': offset, 'address': address, }, 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.`, }, }); } /** * Cancel existing subscription *

    1 credit for API call


    Cancel existing subscription.

    * @param id Subscription ID * @returns void * @throws ApiError */ public static deleteSubscription( id: string, ): CancelablePromise { return __request({ method: 'DELETE', path: `/v3/subscription/${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.`, }, }); } /** * Obtain report for subscription *

    1 credit for API call. Based on the required report type, additional credits may be charged.


    *

    Obtain report from subscription based on its type. Following reports are supported: *

      *
    • ACCOUNT_BALANCE_LIMIT - obtain list of all ledger accounts with account balance above the limit. 1 credit per 50 returned records is charged.
    • *
    • TRANSACTION_HISTORY_REPORT - obtain list of all ledger transaction for last X hours from the time of invocation. 1 credit per 50 returned records is charged.
    • *

    * * @param id Subscription ID * @returns any OK * @throws ApiError */ public static getSubscriptionReport( id: string, ): CancelablePromise<(Array | Array)> { return __request({ method: 'GET', path: `/v3/subscription/report/${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 required perform operation due to logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server while processing the request.`, }, }); } /** * List all executed webhooks *

    1 credit per API call.


    List all webhooks.

    * @param pageSize Max number of items per page is 50. * @param offset Offset to obtain the next page of data. * @param direction Direction of sorting * @param failed Flag indicating whether the webhook was successful or not * @returns WebHook OK * @throws ApiError */ public static getAllWebhooks( pageSize: number, offset?: number, direction?: 'asc' | 'desc', failed?: boolean, ): CancelablePromise> { return __request({ method: 'GET', path: `/v3/subscription/webhook`, query: { 'pageSize': pageSize, 'offset': offset, 'direction': direction, 'failed': failed, }, 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 webhook request *

    1 credit per API call.


    Count of webhooks that were found from /v3/subscription/webhook

    * @param pageSize Max number of items per page is 50. * @param offset Offset to obtain the next page of data. * @param direction Direction of sorting * @param failed Flag indicating whether the webhook was successful or not * @returns EntitiesCount OK * @throws ApiError */ public static getAllWebhooksCount( pageSize: number, offset?: number, direction?: 'asc' | 'desc', failed?: boolean, ): CancelablePromise { return __request({ method: 'GET', path: `/v3/subscription/webhook/count`, query: { 'pageSize': pageSize, 'offset': offset, 'direction': direction, 'failed': failed, }, 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.`, }, }); } }