export type GetApiV1ConvaiOutboundCampaignsCampaignsCampaignIdExportArgs = {campaign_id: string, limit?: (number | null) | undefined, 'xi-api-key'?: (string | null) | undefined}; export type GetApiV1ConvaiOutboundCampaignsCampaignsCampaignIdExportOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Export Outbound Campaign Calls * * GET /v1/convai/outbound-campaigns/campaigns/{campaign_id}/export */ export const getApiV1ConvaiOutboundCampaignsCampaignsCampaignIdExport = async (args: GetApiV1ConvaiOutboundCampaignsCampaignsCampaignIdExportArgs, options: GetApiV1ConvaiOutboundCampaignsCampaignsCampaignIdExportOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.limit != null) query.append("limit", String(args.limit)) if (args['xi-api-key'] != null) headers.set("xi-api-key", String(args['xi-api-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/convai/outbound-campaigns/campaigns/${encodeURIComponent(String(args.campaign_id))}/export${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 res.text() };