export type GetApiOutputsOutputIdFilesRoleArgs = {output_id: string, role: 'excel' | 'pdf' | 'json' | 'instructions', customer_id?: string | undefined}; export type GetApiOutputsOutputIdFilesRoleOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download an output package file * * GET /outputs/{output_id}/files/{role} */ export const getApiOutputsOutputIdFilesRole = async (args: GetApiOutputsOutputIdFilesRoleArgs, options?: GetApiOutputsOutputIdFilesRoleOptions) => { 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(/\/+$/, '')}/outputs/${encodeURIComponent(String(args.output_id))}/files/${encodeURIComponent(String(args.role))}${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() };