export type CreateApiApiPublicWebWhatsappMessageSendPhoneIdMessageArgs = {phoneId: string, stage?: string | undefined, 'x-api-key': string, message?: string | undefined, body: Record | string | {[key: string]: unknown}}; export type CreateApiApiPublicWebWhatsappMessageSendPhoneIdMessageOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send a message * * POST /api/public/web-whatsapp-message/send/{phoneId}/message */ export const createApiApiPublicWebWhatsappMessageSendPhoneIdMessage = async (args: CreateApiApiPublicWebWhatsappMessageSendPhoneIdMessageArgs, options?: CreateApiApiPublicWebWhatsappMessageSendPhoneIdMessageOptions) => { const {baseUrl = "https://api.vambe.me", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.stage != null) query.append("stage", String(args.stage)) if (args['x-api-key'] != null) query.append("x-api-key", String(args['x-api-key'])) if (args.message != null) query.append("message", String(args.message)) const url = `${baseUrl.replace(/\/+$/, '')}/api/public/web-whatsapp-message/send/${encodeURIComponent(String(args.phoneId))}/message${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };