import {z} from 'zod' export type ESignatureEntryPadTypeEnum = 'signature' | 'initials' | 'stamp' | 'date' | 'text' | 'checkbox' | 'name' | 'notary_public_profile_info' | 'email'; export type AnyValue = unknown; export type UpdateApiESignaturePackagesESignaturePackageIdDocumentsDocumentIdEntryPadsIdArgs = {body: {signerId?: string | undefined, type?: ESignatureEntryPadTypeEnum | undefined, left?: number | undefined, top?: number | undefined, height?: number | undefined, width?: number | undefined, pageIndex?: number | undefined, isOptional?: boolean | undefined, metadata?: AnyValue | undefined}}; export type UpdateApiESignaturePackagesESignaturePackageIdDocumentsDocumentIdEntryPadsIdOptions = {baseUrl?: string | undefined, DefaultAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; export const eSignatureEntryPadTypeEnum = z.enum(["signature", "initials", "stamp", "date", "text", "checkbox", "name", "notary_public_profile_info", "email"]); export const anyValue = z.unknown(); export const eSignatureEntryPad = z.object({id: z.string().optional(), signerId: z.string(), type: eSignatureEntryPadTypeEnum, left: z.number(), top: z.number(), height: z.number(), width: z.number(), pageIndex: z.number(), isOptional: z.boolean().optional(), metadata: anyValue.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update an entry pad * * PUT /e-signature-packages/{eSignaturePackageId}/documents/{documentId}/entry-pads/{id} */ export const updateApiESignaturePackagesESignaturePackageIdDocumentsDocumentIdEntryPadsId = async (args: UpdateApiESignaturePackagesESignaturePackageIdDocumentsDocumentIdEntryPadsIdArgs, options?: UpdateApiESignaturePackagesESignaturePackageIdDocumentsDocumentIdEntryPadsIdOptions) => { const {baseUrl = "https://rest.api.pactima.com/v1", fetch: fetchFn = fetch, DefaultAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (DefaultAuthentication !== undefined) headers.set('authorization', `Bearer ${DefaultAuthentication}`) const url = `${baseUrl.replace(/\/+$/, '')}/e-signature-packages/${encodeURIComponent(String(args.eSignaturePackageId))}/documents/${encodeURIComponent(String(args.documentId))}/entry-pads/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 validateResponse(eSignatureEntryPad, await res.json()) };