export type GetApiPublicV1DocumentsIdDownloadProtectedArgs = {id: string, separate_files?: boolean | undefined}; export type GetApiPublicV1DocumentsIdDownloadProtectedOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Completed Document * * GET /public/v1/documents/{id}/download-protected * * Also accepts auth: oauth2 */ export const getApiPublicV1DocumentsIdDownloadProtected = async (args: GetApiPublicV1DocumentsIdDownloadProtectedArgs, options?: GetApiPublicV1DocumentsIdDownloadProtectedOptions) => { 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.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-protected${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() };