export type GetApiUploadsFilenameArgs = {filename: string, customer_id?: string | undefined}; export type GetApiUploadsFilenameOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download one uploaded file * * GET /uploads/{filename} */ export const getApiUploadsFilename = async (args: GetApiUploadsFilenameArgs, options?: GetApiUploadsFilenameOptions) => { 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(/\/+$/, '')}/uploads/${encodeURIComponent(String(args.filename))}${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() };