export type OrderStatusInputDto = {referenceId: string, status: 'pending' | 'processing' | 'partially_shipped' | 'shipped' | 'completed' | 'canceled', description?: string | undefined}; export type SendWhatsappOrderStatusContentDto = {body: string, footer?: string | undefined, orderStatus: OrderStatusInputDto}; export type SendWhatsappOrderStatusMessageDto = {to?: unknown | undefined, from?: unknown | undefined, messageId?: string | undefined, content: SendWhatsappOrderStatusContentDto}; export type CreateApiWhatsappMessageOrderStatusArgs = {body: SendWhatsappOrderStatusMessageDto}; export type CreateApiWhatsappMessageOrderStatusOptions = {baseUrl?: string | undefined, basic?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send Whatsapp Order Status Message * * POST /whatsapp/message/order/status */ export const createApiWhatsappMessageOrderStatus = async (args: CreateApiWhatsappMessageOrderStatusArgs, options?: CreateApiWhatsappMessageOrderStatusOptions) => { const {baseUrl = "https://public.doubletick.io", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basic !== undefined) headers.set("Authorization", basic) const url = `${baseUrl.replace(/\/+$/, '')}/whatsapp/message/order/status${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 };