UNPKG

@prass/botpress-native

Version:

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

43 lines (40 loc) 1.47 kB
import { prepareHeaders } from '../../utils/prepareHeaders.js'; import { handleError } from '../../utils/errorHandler.js'; import { z } from 'zod'; const RemoveParticipantParamsSchema = z.object({ conversationId: z.string().nonempty("Conversation ID is required"), userId: z.string().nonempty("User ID is required"), }); /** * Internal handler for removing a participant from a conversation. * @param this - Botpress instance context * @param params - Parameters containing conversationId and userId * @returns Promise resolving to void upon successful removal * @throws Error if prerequisites are missing or API call fails */ async function handleRemoveParticipant({ conversationId, userId }) { if (!this.userKey) throw new Error(this.errors.userNotCreated); const { conversationId: cid, userId: uid } = RemoveParticipantParamsSchema.parse({ conversationId, userId }); try { const url = this.ChatApiBaseUrl.getUrl([ "conversations", cid, "participants", uid, ]); await this.axiosInstance.request({ url, method: "DELETE", headers: prepareHeaders({ "x-user-key": this.userKey, }), timeout: this.config.timeout, }); } catch (e) { return handleError(e, "RemoveParticipant"); } } export { handleRemoveParticipant }; //# sourceMappingURL=removeParticipants.js.map