export type GetApiApiV2AccountsAccountUidFeedExportArgs = {accountUid: string, start: string, end?: string | undefined}; export type GetApiApiV2AccountsAccountUidFeedExportOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a Feed Export for a given date range * * GET /api/v2/accounts/{accountUid}/feed-export */ export const getApiApiV2AccountsAccountUidFeedExport = async (args: GetApiApiV2AccountsAccountUidFeedExportArgs, options: GetApiApiV2AccountsAccountUidFeedExportOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.start != null) query.append("start", String(args.start)) if (args.end != null) query.append("end", String(args.end)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/accounts/${encodeURIComponent(String(args.accountUid))}/feed-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() };