import {z} from 'zod' export type DeleteApiWorkflowsIdSignStatusScheduledSendArgs = {'x-as-user-email'?: string | undefined, 'x-as-user-id'?: string | undefined, id: string}; export type DeleteApiWorkflowsIdSignStatusScheduledSendOptions = {baseUrl?: string | undefined, sec0?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; export const signStatusInternalSigner = z.object({name: z.string(), email: z.string(), roleName: z.string(), status: z.enum(["pending", "declined", "sent", "viewed", "signed"]), isWetSigned: z.boolean().optional(), delegates: z.array(z.object({name: z.string().optional(), email: z.string().optional()})).optional(), routingOrder: z.number().int().gte(-1).optional(), signsOutsideIronclad: z.boolean().optional(), type: z.literal("internal"), userId: z.string().optional()}); export const signStatusExternalSigner = z.object({name: z.string(), email: z.string(), roleName: z.string(), status: z.enum(["pending", "declined", "sent", "viewed", "signed"]), isWetSigned: z.boolean().optional(), delegates: z.array(z.object({name: z.string().optional(), email: z.string().optional()})).optional(), routingOrder: z.number().int().gte(-1).optional(), signsOutsideIronclad: z.boolean().optional(), type: z.literal("external")}); export const signStatusModel = z.object({signers: z.array(z.union([signStatusInternalSigner, signStatusExternalSigner])).optional(), routing: z.enum(["sequential", "parallel"]).optional(), status: z.enum(["not_sent", "sent", "action_required", "complete"]).optional(), requireSignedDocumentUpload: z.boolean().optional(), provider: z.enum(["Ironclad Clickwrap", "Ironclad Signature", "Ironclad Signature (Legacy)", "DocuSign", "Adobe Sign", "DropboxSign", "Custom Provider", "Demo", "None"]).optional(), scheduledSend: z.object({notifyAt: z.string(), reminder: z.object({daysBefore: z.number().int().gte(1).lte(7), reminderDate: z.string()}).optional()}).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 }; /** * Delete Scheduled Signature Request * * DELETE /workflows/{id}/sign-status/scheduled-send */ export const deleteApiWorkflowsIdSignStatusScheduledSend = async (args: DeleteApiWorkflowsIdSignStatusScheduledSendArgs, options?: DeleteApiWorkflowsIdSignStatusScheduledSendOptions) => { const {baseUrl = "https://ironcladapp.com/public/api/v1", fetch: fetchFn = fetch, sec0, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-as-user-email'] != null) headers.set("x-as-user-email", String(args['x-as-user-email'])) if (args['x-as-user-id'] != null) headers.set("x-as-user-id", String(args['x-as-user-id'])) if (sec0 !== undefined) headers.set("Authorization", sec0) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/workflows/${encodeURIComponent(String(args.id))}/sign-status/scheduled-send${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(signStatusModel, await res.json()) };