export type GetApiImportRunsRunIdRawPackageArgs = {run_id: string, customer_id?: string | undefined}; export type GetApiImportRunsRunIdRawPackageOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download an import run's raw package * * GET /import-runs/{run_id}/raw-package */ export const getApiImportRunsRunIdRawPackage = async (args: GetApiImportRunsRunIdRawPackageArgs, options?: GetApiImportRunsRunIdRawPackageOptions) => { 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/octet-stream") 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(/\/+$/, '')}/import-runs/${encodeURIComponent(String(args.run_id))}/raw-package${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() };