export type GetApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdArgs = {accountId: string, documentId: string, envelopeId: string, certificate?: string | undefined, documents_by_userid?: string | undefined, encoding?: string | undefined, encrypt?: string | undefined, language?: string | undefined, recipient_id?: string | undefined, shared_user_id?: string | undefined, show_changes?: string | undefined, watermark?: string | undefined}; export type GetApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieves a single document or all documents from an envelope. * * GET /v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId} */ export const getApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentId = async (args: GetApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdArgs, options?: GetApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdOptions) => { 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.certificate != null) query.append("certificate", String(args.certificate)) if (args.documents_by_userid != null) query.append("documents_by_userid", String(args.documents_by_userid)) if (args.encoding != null) query.append("encoding", String(args.encoding)) if (args.encrypt != null) query.append("encrypt", String(args.encrypt)) if (args.language != null) query.append("language", String(args.language)) if (args.recipient_id != null) query.append("recipient_id", String(args.recipient_id)) if (args.shared_user_id != null) query.append("shared_user_id", String(args.shared_user_id)) if (args.show_changes != null) query.append("show_changes", String(args.show_changes)) if (args.watermark != null) query.append("watermark", String(args.watermark)) const url = `${baseUrl.replace(/\/+$/, '')}/v2.1/accounts/${encodeURIComponent(String(args.accountId))}/envelopes/${encodeURIComponent(String(args.envelopeId))}/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() };