export type GetApiUploadsExportArgs = {customer_id?: string | undefined}; export type GetApiUploadsExportOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export all uploads as a zip * * GET /uploads/export */ export const getApiUploadsExport = async (args: GetApiUploadsExportArgs, options?: GetApiUploadsExportOptions) => { const {baseUrl = "https://api.app.lastaccountingcompany.com/portal", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/zip") if (args.customer_id != null) query.append("customer_id", String(args.customer_id)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/uploads/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.blob() };