export type GetApiV1WhatsappChannelIdCampaignsReportArgs = {channelId: string, from: string, to: string}; export type GetApiV1WhatsappChannelIdCampaignsReportOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reporte de campaƱas * * GET /v1/whatsapp/{channelId}/campaigns/report */ export const getApiV1WhatsappChannelIdCampaignsReport = async (args: GetApiV1WhatsappChannelIdCampaignsReportArgs, options?: GetApiV1WhatsappChannelIdCampaignsReportOptions) => { const {baseUrl = "https://connect.cliengo.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/whatsapp/${encodeURIComponent(String(args.channelId))}/campaigns/report${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 undefined };