UNPKG

@prass/botpress-native

Version:

A simple and powerful SDK for integrating Botpress Chat API with React Native,

39 lines (36 loc) 1.48 kB
import { prepareHeaders } from '../../utils/prepareHeaders.js'; import { handleError } from '../../utils/errorHandler.js'; import { z } from 'zod'; const ListParticipantsParamsSchema = z.object({ conversationId: z.string().nonempty("Conversation ID is required"), nextToken: z.string().optional(), }); /** * Internal handler for retrieving participants of a conversation. * @param this - Botpress instance context * @param params - Parameters containing conversationId and optional nextToken * @returns Promise resolving to the list of participants and pagination metadata * @throws Error if prerequisites are missing or API call fails */ async function handleListParticipants({ conversationId, nextToken }) { if (!this.userKey) throw new Error(this.errors.userNotCreated); const { conversationId: cid, nextToken: nxt } = ListParticipantsParamsSchema.parse({ conversationId, nextToken }); try { const url = this.ChatApiBaseUrl.getUrl(["conversations", cid, "participants"], { nextToken: nxt }); const { data } = await this.axiosInstance.request({ url, method: "GET", headers: prepareHeaders({ "x-user-key": this.userKey, }), timeout: this.config.timeout, }); return data; } catch (e) { return handleError(e, "ListParticipants"); } } export { handleListParticipants }; //# sourceMappingURL=listParticipants.js.map