export type GetApiPublicV1DocumentsIdDownloadArgs = {id: string, watermark_color?: string | undefined, watermark_font_size?: number | undefined, watermark_opacity?: number | undefined, watermark_text?: string | undefined, separate_files?: boolean | undefined}; export type GetApiPublicV1DocumentsIdDownloadOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Document Download * * GET /public/v1/documents/{id}/download * * Also accepts auth: oauth2 */ export const getApiPublicV1DocumentsIdDownload = async (args: GetApiPublicV1DocumentsIdDownloadArgs, options?: GetApiPublicV1DocumentsIdDownloadOptions) => { const {baseUrl = "https://api.pandadoc.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.watermark_color != null) query.append("watermark_color", String(args.watermark_color)) if (args.watermark_font_size != null) query.append("watermark_font_size", String(args.watermark_font_size)) if (args.watermark_opacity != null) query.append("watermark_opacity", String(args.watermark_opacity)) if (args.watermark_text != null) query.append("watermark_text", String(args.watermark_text)) if (args.separate_files != null) query.append("separate_files", String(args.separate_files)) if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/documents/${encodeURIComponent(String(args.id))}/download${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() };