export type GetApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdArgs = {accountId: string, documentId: string, templateId: string, encrypt?: string | undefined, file_type?: string | undefined, show_changes?: string | undefined}; export type GetApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Gets PDF documents from a template. * * GET /v2.1/accounts/{accountId}/templates/{templateId}/documents/{documentId} */ export const getApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentId = async (args: GetApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdArgs, options?: GetApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdOptions) => { const {baseUrl = "https://www.docusign.net/restapi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.encrypt != null) query.append("encrypt", String(args.encrypt)) if (args.file_type != null) query.append("file_type", String(args.file_type)) if (args.show_changes != null) query.append("show_changes", String(args.show_changes)) const url = `${baseUrl.replace(/\/+$/, '')}/v2.1/accounts/${encodeURIComponent(String(args.accountId))}/templates/${encodeURIComponent(String(args.templateId))}/documents/${encodeURIComponent(String(args.documentId))}${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() };