export type GetApiTemplatesWhatsappCloudArgs = {offset?: number | undefined, limit?: number | undefined, integration_id?: number | undefined, status?: ('APPROVED' | 'MISSING_VARS' | 'REJECTED' | 'PENDING') | undefined}; export type GetApiTemplatesWhatsappCloudOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Listar templates whatsapp cloud * * GET /templates/whatsapp_cloud */ export const getApiTemplatesWhatsappCloud = async (args: GetApiTemplatesWhatsappCloudArgs, options?: GetApiTemplatesWhatsappCloudOptions) => { const {baseUrl = "https://api.tiflux.com/api/v2", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.offset != null) query.append("offset", String(args.offset)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.integration_id != null) query.append("integration_id", String(args.integration_id)) if (args.status != null) query.append("status", String(args.status)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/templates/whatsapp_cloud${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };