/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of recipient associated with the document (will be `Contractor` for Contractor Documents) */ export const RecipientType = { Company: "Company", Employee: "Employee", Contractor: "Contractor", } as const; /** * The type of recipient associated with the document (will be `Contractor` for Contractor Documents) */ export type RecipientType = ClosedEnum; export type Pages = { /** * Image URL for the page */ imageUrl?: string | undefined; /** * Page number */ pageNumber?: number | undefined; }; export type Fields = { /** * Unique identifier of the field. May be null for custom fields that do not correspond to a known Gusto-managed key mapping. */ key?: string | null | undefined; /** * Auto-filled value of the field */ value?: string | null | undefined; /** * X-coordinate location of the field on the page. May be null when the field has no positioning information. */ x?: number | null | undefined; /** * Y-coordinate location of the field on the page. May be null when the field has no positioning information. */ y?: number | null | undefined; /** * Width of the field. May be null when the field has no positioning information. */ width?: number | null | undefined; /** * Height of the field. May be null when the field has no positioning information. */ height?: number | null | undefined; /** * Page number of the field. May be null when the field has no positioning information. */ pageNumber?: number | null | undefined; /** * The field's data type */ dataType?: string | undefined; /** * Whether the field is required */ required?: boolean | undefined; }; export type Document = { /** * The UUID of the document */ uuid?: string | undefined; /** * The title of the document */ title?: string | undefined; /** * The type identifier of the document */ name?: string | undefined; /** * The type of recipient associated with the document (will be `Contractor` for Contractor Documents) */ recipientType?: RecipientType | undefined; /** * Unique identifier for the recipient associated with the document */ recipientUuid?: string | undefined; /** * List of the document's pages and associated image URLs. This is only returned for documents with `required_signing` = `true`, and can be used for signing preparation. */ pages?: Array | undefined; /** * List of the document's fields and associated data. Values are set for auto-filled fields. This is only returned for documents with `required_signing` = `true`, and can be used for signing preparation. */ fields?: Array | undefined; /** * When the document was signed (will be `null` if unsigned) */ signedAt?: string | null | undefined; /** * The description of the document */ description?: string | undefined; /** * A boolean flag that indicates whether the document needs signing or not. Note that this value will change after the document is signed. */ requiresSigning?: boolean | undefined; /** * If the document is in a draft state */ draft?: boolean | undefined; /** * The year of this document. This value is nullable and will not be present on all documents. */ year?: number | null | undefined; /** * The quarter of this document. This value is nullable and will not be present on all documents. */ quarter?: number | null | undefined; }; /** @internal */ export const RecipientType$inboundSchema: z.ZodNativeEnum< typeof RecipientType > = z.nativeEnum(RecipientType); /** @internal */ export const Pages$inboundSchema: z.ZodType = z .object({ image_url: z.string().optional(), page_number: z.number().int().optional(), }).transform((v) => { return remap$(v, { "image_url": "imageUrl", "page_number": "pageNumber", }); }); export function pagesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Pages$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Pages' from JSON`, ); } /** @internal */ export const Fields$inboundSchema: z.ZodType = z .object({ key: z.nullable(z.string()).optional(), value: z.nullable(z.string()).optional(), x: z.nullable(z.number().int()).optional(), y: z.nullable(z.number().int()).optional(), width: z.nullable(z.number().int()).optional(), height: z.nullable(z.number().int()).optional(), page_number: z.nullable(z.number().int()).optional(), data_type: z.string().optional(), required: z.boolean().optional(), }).transform((v) => { return remap$(v, { "page_number": "pageNumber", "data_type": "dataType", }); }); export function fieldsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields' from JSON`, ); } /** @internal */ export const Document$inboundSchema: z.ZodType< Document, z.ZodTypeDef, unknown > = z.object({ uuid: z.string().optional(), title: z.string().optional(), name: z.string().optional(), recipient_type: RecipientType$inboundSchema.optional(), recipient_uuid: z.string().optional(), pages: z.array(z.lazy(() => Pages$inboundSchema)).optional(), fields: z.array(z.lazy(() => Fields$inboundSchema)).optional(), signed_at: z.nullable(z.string()).optional(), description: z.string().optional(), requires_signing: z.boolean().optional(), draft: z.boolean().optional(), year: z.nullable(z.number().int()).optional(), quarter: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { "recipient_type": "recipientType", "recipient_uuid": "recipientUuid", "signed_at": "signedAt", "requires_signing": "requiresSigning", }); }); export function documentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Document$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Document' from JSON`, ); }