UNPKG

@prass/botpress-native

Version:

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

37 lines (34 loc) 1.2 kB
import { prepareHeaders } from '../../utils/prepareHeaders.js'; import { handleError } from '../../utils/errorHandler.js'; import { z } from 'zod'; const DeleteMessageParamsSchema = z.object({ id: z.string().nonempty("Message ID is required"), }); /** * Internal handler for deleting a specific message. * @param this - Botpress instance context * @param params - Parameters containing the message id * @returns Promise resolving to void upon successful deletion * @throws Error if prerequisites are missing or API call fails */ async function handleDeleteMessage({ id }) { if (!this.userKey) throw new Error(this.errors.userNotCreated); const { id: mid } = DeleteMessageParamsSchema.parse({ id }); try { const url = this.ChatApiBaseUrl.getUrl(["messages", mid]); await this.axiosInstance.request({ url, method: "DELETE", headers: prepareHeaders({ "x-user-key": this.userKey, }), timeout: this.config.timeout, }); } catch (e) { return handleError(e, "DeleteMessage"); } } export { handleDeleteMessage }; //# sourceMappingURL=deleteMessage.js.map