export type SendInteractiveMessageButtonDto = {id: string, title: string}; export type SendInteractiveMediaMessageContentDto = {body: string, footer?: string | undefined, buttons: Array, fileName?: string | undefined, mediaUrl: string, mediaType: 'image/jpeg' | 'image/png' | 'video/mp4' | 'application/pdf'}; export type SendWhatsappInteractiveMediaMessageDto = {from?: unknown | undefined, to: unknown, messageId?: string | undefined, content: SendInteractiveMediaMessageContentDto}; export type CreateApiWhatsappMessageInteractiveMediaArgs = {body: SendWhatsappInteractiveMediaMessageDto}; export type CreateApiWhatsappMessageInteractiveMediaOptions = {baseUrl?: string | undefined, basic?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send Whatsapp Interactive Media Message * * POST /whatsapp/message/interactive/media */ export const createApiWhatsappMessageInteractiveMedia = async (args: CreateApiWhatsappMessageInteractiveMediaArgs, options?: CreateApiWhatsappMessageInteractiveMediaOptions) => { 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/interactive/media${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 };