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 { ApnsToken, apnsTokenResponse } from './models/apns-token.js'; import { ApnsTokenCollection, apnsTokenCollectionResponse } from './models/apns-token-collection.js'; import { CategoryDeliveryConfig, categoryDeliveryConfigRequest, categoryDeliveryConfigResponse, } from './models/category-delivery-config.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 { FcmToken, fcmTokenResponse } from './models/fcm-token.js'; import { FcmTokenCollection, fcmTokenCollectionResponse } from './models/fcm-token-collection.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 { TeamsToken, teamsTokenResponse } from './models/teams-token.js'; import { TeamsTokenCollection, teamsTokenCollectionResponse } from './models/teams-token-collection.js'; import { WebPushToken, webPushTokenResponse } from './models/web-push-token.js'; import { WebPushTokenCollection, webPushTokenCollectionResponse } from './models/web-push-token-collection.js'; import { ListUserApnsTokensParams, ListUserExpoTokensParams, ListUserFcmTokensParams, ListUserInboxTokensParams, ListUserMagicbellSlackbotTokensParams, ListUserSlackTokensParams, ListUserTeamsTokensParams, ListUserWebPushTokensParams, } 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 { /** * Save the channels configuration for a given key. * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async saveChannelsConfig( body: CategoryDeliveryConfig, 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') .setRequestSchema(categoryDeliveryConfigRequest) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: categoryDeliveryConfigResponse, 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 the channels config for a given key. * @param {string} key - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchChannelsConfig(key: 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/{key}') .setRequestSchema(z.any()) .addAccessTokenAuth(this.config.token, 'Bearer') .setRequestContentType(ContentType.Json) .addResponse({ schema: categoryDeliveryConfigResponse, contentType: ContentType.Json, status: 200, }) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .addPathParam({ key: 'key', value: key, }) .build(); return this.client.call(request); } /** * Lists all Inbox tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserInboxTokens( userId: string, params?: ListUserInboxTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific Inbox token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserInboxToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's Inbox token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserInboxToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all APNs tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserApnsTokens( userId: string, params?: ListUserApnsTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific APNs token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserApnsToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's APNs token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserApnsToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all Expo tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserExpoTokens( userId: string, params?: ListUserExpoTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific Expo token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserExpoToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's Expo token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserExpoToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all FCM tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserFcmTokens( userId: string, params?: ListUserFcmTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific FCM token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserFcmToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's FCM token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserFcmToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all MagicBell SlackBot tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserMagicbellSlackbotTokens( userId: string, params?: ListUserMagicbellSlackbotTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific MagicBell SlackBot token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserMagicbellSlackbotToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's MagicBell SlackBot token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserMagicbellSlackbotToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all Slack tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserSlackTokens( userId: string, params?: ListUserSlackTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific Slack token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserSlackToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's Slack token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserSlackToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all Teams tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserTeamsTokens( userId: string, params?: ListUserTeamsTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific Teams token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserTeamsToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's Teams token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserTeamsToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Lists all Web Push tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens. * @param {string} userId - * @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 listUserWebPushTokens( userId: string, params?: ListUserWebPushTokensParams, requestConfig?: RequestConfig, ): Promise> { const request = new RequestBuilder() .setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT) .setConfig(this.config) .setMethod('GET') .setPath('/users/{user_id}/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) .addPathParam({ key: 'user_id', value: userId, }) .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); } /** * Fetches a specific Web Push token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async fetchUserWebPushToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } /** * Deletes a specific user's Web Push token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone. * @param {string} userId - * @param {string} tokenId - * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation. * @returns {Promise>} - OK */ async deleteUserWebPushToken( userId: string, 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('/users/{user_id}/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: 'user_id', value: userId, }) .addPathParam({ key: 'token_id', value: tokenId, }) .build(); return this.client.call(request); } }