export type UpdateApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdArgs = {accountId: string, documentId: string, envelopeId: string, body: BodyInit}; export type UpdateApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adds or replaces a document in an existing envelope. * * PUT /v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId} */ export const updateApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentId = async (args: UpdateApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdArgs, options?: UpdateApiV21AccountsAccountIdEnvelopesEnvelopeIdDocumentsDocumentIdOptions) => { const {baseUrl = "https://www.docusign.net/restapi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/pdf") headers.set('accept', "*/*") 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: "PUT", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };