import { z } from 'zod'; import { Environment } from '../../http/environment.js'; import { ThrowableError } from '../../http/errors/throwable-error.js'; import { SerializationStyle } from '../../http/serialization/base-serializer.js'; import { RequestBuilder } from '../../http/transport/request-builder.js'; import { ContentType, HttpResponse, RequestConfig } from '../../http/types.js'; import { BaseService } from '../base-service.js'; import { WebPushTokenPayload, webPushTokenPayloadRequest, webPushTokenPayloadResponse, } from '../common/web-push-token-payload.js'; import { ApnsToken, apnsTokenResponse } from './models/apns-token.js'; import { ApnsTokenCollection, apnsTokenCollectionResponse } from './models/apns-token-collection.js'; import { ApnsTokenPayload, apnsTokenPayloadRequest, apnsTokenPayloadResponse } from './models/apns-token-payload.js'; import { DiscardResult, discardResultResponse } from './models/discard-result.js'; import { ExpoToken, expoTokenResponse } from './models/expo-token.js'; import { ExpoTokenCollection, expoTokenCollectionResponse } from './models/expo-token-collection.js'; import { ExpoTokenPayload, expoTokenPayloadRequest, expoTokenPayloadResponse } from './models/expo-token-payload.js'; import { FcmToken, fcmTokenResponse } from './models/fcm-token.js'; import { FcmTokenCollection, fcmTokenCollectionResponse } from './models/fcm-token-collection.js'; import { FcmTokenPayload, fcmTokenPayloadRequest, fcmTokenPayloadResponse } from './models/fcm-token-payload.js'; import { InboxToken, inboxTokenRequest, inboxTokenResponse1 } from './models/inbox-token.js'; import { InboxTokenResponse, inboxTokenResponseResponse } from './models/inbox-token-response.js'; import { InboxTokenResponseCollection, inboxTokenResponseCollectionResponse, } from './models/inbox-token-response-collection.js'; import { SlackToken, slackTokenResponse } from './models/slack-token.js'; import { SlackTokenCollection, slackTokenCollectionResponse } from './models/slack-token-collection.js'; import { SlackTokenPayload, slackTokenPayloadRequest, slackTokenPayloadResponse, } from './models/slack-token-payload.js'; import { TeamsToken, teamsTokenResponse } from './models/teams-token.js'; import { TeamsTokenCollection, teamsTokenCollectionResponse } from './models/teams-token-collection.js'; import { TeamsTokenPayload, teamsTokenPayloadRequest, teamsTokenPayloadResponse, } from './models/teams-token-payload.js'; import { UserPreferences, userPreferencesRequest, userPreferencesResponse } from './models/user-preferences.js'; import { WebPushToken, webPushTokenResponse } from './models/web-push-token.js'; import { WebPushTokenCollection, webPushTokenCollectionResponse } from './models/web-push-token-collection.js'; import { ListApnsTokensParams, ListExpoTokensParams, ListFcmTokensParams, ListInboxTokensParams, ListMagicbellSlackbotTokensParams, ListSlackTokensParams, ListTeamsTokensParams, ListWebPushTokensParams, } from './request-params.js'; /** * Service class for ChannelsService operations. * Provides methods to interact with ChannelsService-related API endpoints. * All methods return promises and handle request/response serialization automatically. */ export class ChannelsService extends BaseService { /** * Lists all Inbox tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listInboxTokens( params?: ListInboxTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/in_app/inbox/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: inboxTokenResponseCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the Inbox token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveInboxToken(body: InboxToken, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/in_app/inbox/tokens') .setRequestSchema(inboxTokenRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: inboxTokenResponse1, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific Inbox token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchInboxToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/in_app/inbox/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: inboxTokenResponseResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's Inbox tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteInboxToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/in_app/inbox/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all APNs tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listApnsTokens( params?: ListApnsTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/mobile_push/apns/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: apnsTokenCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the APNs token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveApnsToken(body: ApnsTokenPayload, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/mobile_push/apns/tokens') .setRequestSchema(apnsTokenPayloadRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: apnsTokenPayloadResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific APNs token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchApnsToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/mobile_push/apns/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: apnsTokenResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's APNs tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteApnsToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/mobile_push/apns/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all Expo tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listExpoTokens( params?: ListExpoTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/mobile_push/expo/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: expoTokenCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the Expo token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveExpoToken(body: ExpoTokenPayload, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/mobile_push/expo/tokens') .setRequestSchema(expoTokenPayloadRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: expoTokenPayloadResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific Expo token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchExpoToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/mobile_push/expo/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: expoTokenResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's Expo tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteExpoToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/mobile_push/expo/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all FCM tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listFcmTokens( params?: ListFcmTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/mobile_push/fcm/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: fcmTokenCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the FCM token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveFcmToken(body: FcmTokenPayload, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/mobile_push/fcm/tokens') .setRequestSchema(fcmTokenPayloadRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: fcmTokenPayloadResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific FCM token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchFcmToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/mobile_push/fcm/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: fcmTokenResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's FCM tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteFcmToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/mobile_push/fcm/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all MagicBell SlackBot tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listMagicbellSlackbotTokens( params?: ListMagicbellSlackbotTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/slack/magicbell_slackbot/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: slackTokenCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the MagicBell SlackBot token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveMagicbellSlackbotToken( body: SlackTokenPayload, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/slack/magicbell_slackbot/tokens') .setRequestSchema(slackTokenPayloadRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: slackTokenPayloadResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific MagicBell SlackBot token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchMagicbellSlackbotToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/slack/magicbell_slackbot/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: slackTokenResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's MagicBell SlackBot tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteMagicbellSlackbotToken( tokenId: string, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/slack/magicbell_slackbot/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all Slack tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listSlackTokens( params?: ListSlackTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/slack/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: slackTokenCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the Slack token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveSlackToken( body: SlackTokenPayload, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/slack/tokens') .setRequestSchema(slackTokenPayloadRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: slackTokenPayloadResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific Slack token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchSlackToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/slack/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: slackTokenResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's Slack tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteSlackToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/slack/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all Teams tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listTeamsTokens( params?: ListTeamsTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/teams/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: teamsTokenCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the Teams token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveTeamsToken( body: TeamsTokenPayload, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/teams/tokens') .setRequestSchema(teamsTokenPayloadRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: teamsTokenPayloadResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific Teams token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchTeamsToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/teams/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: teamsTokenResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's Teams tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteTeamsToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/teams/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Fetch a user's channel delivery preferences. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserPreferences(requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/user_preferences') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: userPreferencesResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .build(); return this.client.call(request); } /** * Save a user's channel preferences. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - No Content */ async saveUserPreferences(body: UserPreferences, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/user_preferences') .setRequestSchema(userPreferencesRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: z.undefined(), contentType: ContentType.NoContent, status: 204, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Lists all Web Push tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. * @param {number} [params.limit] - defines the maximum number of items to return per page (default: 50) * @param {string} [params.startingAfter] - a cursor for use in pagination, points to the last ID in previous page * @param {string} [params.endingBefore] - a cursor for use in pagination, points to the first ID in next page * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async listWebPushTokens( params?: ListWebPushTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/web_push/tokens') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: webPushTokenCollectionResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addQueryParam({ key: 'limit', value: params?.limit, }) .addQueryParam({ key: 'starting_after', value: params?.startingAfter, }) .addQueryParam({ key: 'ending_before', value: params?.endingBefore, }) .build(); return this.client.call(request); } /** * Saves the Web Push token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveWebPushToken( body: WebPushTokenPayload, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('PUT') .setPath('/channels/web_push/tokens') .setRequestSchema(webPushTokenPayloadRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: webPushTokenPayloadResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); return this.client.call(request); } /** * Fetches details of a specific Web Push token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchWebPushToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/channels/web_push/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: webPushTokenResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes one of the authenticated user's Web Push tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens. * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteWebPushToken(tokenId: string, requestConfig?: RequestConfig): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('DELETE') .setPath('/channels/web_push/tokens/{token_id}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: discardResultResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } }