export type CreateApiV3WhatsappApiFlowsIdPublicationsPublicationIdPublishArgs = {id: string, publicationId: string}; export type CreateApiV3WhatsappApiFlowsIdPublicationsPublicationIdPublishOptions = {baseUrl: string, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Publicar WhatsApp Flow na Meta * * POST /v3/whatsapp-api/flows/{id}/publications/{publicationId}/publish */ export const createApiV3WhatsappApiFlowsIdPublicationsPublicationIdPublish = async (args: CreateApiV3WhatsappApiFlowsIdPublicationsPublicationIdPublishArgs, options: CreateApiV3WhatsappApiFlowsIdPublicationsPublicationIdPublishOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v3/whatsapp-api/flows/${encodeURIComponent(String(args.id))}/publications/${encodeURIComponent(String(args.publicationId))}/publish${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };