export type SendInteractiveMediaCarouselBodyDto = {text: string}; export type CarouselCardHeaderMediaDto = {link: string}; export type CarouselCardHeaderDto = {type: 'image' | 'video', image?: CarouselCardHeaderMediaDto | undefined, video?: CarouselCardHeaderMediaDto | undefined}; export type CarouselCardBodyDto = {text: string}; export type CarouselCardCtaUrlParametersDto = {display_text: string, url: string}; export type CarouselCardQuickReplyButtonDto = {id: string, title: string}; export type CarouselCardActionDto = {type: 'cta_url' | 'quick_reply', name?: 'cta_url' | undefined, parameters?: CarouselCardCtaUrlParametersDto | undefined, buttons?: Array | undefined}; export type CarouselCardDto = {header: CarouselCardHeaderDto, body?: CarouselCardBodyDto | undefined, action: CarouselCardActionDto}; export type SendInteractiveMediaCarouselContentDto = {body: SendInteractiveMediaCarouselBodyDto, cards: Array}; export type SendWhatsappInteractiveMediaCarouselMessageDto = {from: unknown, to: unknown, messageId?: string | undefined, content: SendInteractiveMediaCarouselContentDto}; export type CreateApiWhatsappMessageInteractiveMediaCarouselArgs = {body: SendWhatsappInteractiveMediaCarouselMessageDto}; export type CreateApiWhatsappMessageInteractiveMediaCarouselOptions = {baseUrl?: string | undefined, basic?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send Whatsapp Interactive Media Carousel Message * * POST /whatsapp/message/interactive/media-carousel */ export const createApiWhatsappMessageInteractiveMediaCarousel = async (args: CreateApiWhatsappMessageInteractiveMediaCarouselArgs, options?: CreateApiWhatsappMessageInteractiveMediaCarouselOptions) => { 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-carousel${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 };