export type OpenTicketDto = {contact_name?: string | undefined, to_phone_number: number | string, contact_metadata: {[key: string]: unknown}, ticket_metadata: {[key: string]: unknown}, integration_data: {[key: string]: unknown}, email?: string | undefined, message: {templateId?: string | undefined, content?: string | undefined, ai_generated?: boolean | undefined}, stage_id: string}; export type CreateApiApiPublicTicketOpenWhatsappPhoneIdArgs = {phoneId: string, 'x-api-key': string, body: OpenTicketDto}; export type CreateApiApiPublicTicketOpenWhatsappPhoneIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Open a new ticket for whatsapp * * POST /api/public/ticket/open/whatsapp/{phoneId} */ export const createApiApiPublicTicketOpenWhatsappPhoneId = async (args: CreateApiApiPublicTicketOpenWhatsappPhoneIdArgs, options?: CreateApiApiPublicTicketOpenWhatsappPhoneIdOptions) => { 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['x-api-key'] != null) headers.set("x-api-key", String(args['x-api-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/public/ticket/open/whatsapp/${encodeURIComponent(String(args.phoneId))}${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 };