export type ErrorDetails = {errorCode?: string | undefined, message?: string | undefined}; export type NameValue = {errorDetails?: ErrorDetails | undefined, name?: string | undefined, originalValue?: string | undefined, value?: string | undefined}; export type DocumentFieldsInformation = {documentFields?: Array | undefined}; export type CreateApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdFieldsArgs = {accountId: string, documentId: string, templateId: string, body: DocumentFieldsInformation}; export type CreateApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdFieldsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates custom document fields in an existing template document. * * POST /v2.1/accounts/{accountId}/templates/{templateId}/documents/{documentId}/fields */ export const createApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdFields = async (args: CreateApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdFieldsArgs, options?: CreateApiV21AccountsAccountIdTemplatesTemplateIdDocumentsDocumentIdFieldsOptions) => { const {baseUrl = "https://www.docusign.net/restapi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v2.1/accounts/${encodeURIComponent(String(args.accountId))}/templates/${encodeURIComponent(String(args.templateId))}/documents/${encodeURIComponent(String(args.documentId))}/fields${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(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() };