export type GetApiApiV1DownloadsRequestIdArgs = {request_id: string}; export type GetApiApiV1DownloadsRequestIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Download the resulting PDF for a given request * * * GET /api/v1/downloads/{request_id} */ export const getApiApiV1DownloadsRequestId = async (args: GetApiApiV1DownloadsRequestIdArgs, options: GetApiApiV1DownloadsRequestIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/downloads/${encodeURIComponent(String(args.request_id))}${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() };