export type GetApiRenderRenderIdArgs = {renderId: string, 'carbone-version'?: string | undefined, download?: boolean | undefined}; export type GetApiRenderRenderIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve a generated document. * * GET /render/{renderId} */ export const getApiRenderRenderId = async (args: GetApiRenderRenderIdArgs, options?: GetApiRenderRenderIdOptions) => { const {baseUrl = "https://api.carbone.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args['carbone-version'] != null) headers.set("carbone-version", String(args['carbone-version'])) if (args.download != null) query.append("download", String(args.download)) const url = `${baseUrl.replace(/\/+$/, '')}/render/${encodeURIComponent(String(args.renderId))}${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() };