/* * 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 { DocumentSigned, DocumentSigned$inboundSchema, } from "../components/documentsigned.js"; import { HTTPMetadata, HTTPMetadata$inboundSchema, } from "../components/httpmetadata.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export const PutV1ContractorDocumentSignHeaderXGustoAPIVersion = { TwoThousandAndTwentyFiveMinus06Minus15: "2025-06-15", } as const; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export type PutV1ContractorDocumentSignHeaderXGustoAPIVersion = ClosedEnum< typeof PutV1ContractorDocumentSignHeaderXGustoAPIVersion >; export type Fields = { /** * Unique identifier of the field */ key?: string | undefined; /** * Value for the field */ value?: string | undefined; }; export type PutV1ContractorDocumentSignRequestBody = { /** * List of fields and the values they will be set to. */ fields: Array; /** * Whether you agree to sign electronically */ agree: boolean; /** * The IP address of the signatory who signed the form. You must provide the IP address with either this parameter OR you can leave out this parameter and set the IP address in the request header using the `x-gusto-client-ip` header instead. */ signedByIpAddress?: string | undefined; }; export type PutV1ContractorDocumentSignRequest = { /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ xGustoAPIVersion?: | PutV1ContractorDocumentSignHeaderXGustoAPIVersion | undefined; /** * The UUID of the document */ documentUuid: string; /** * Optional header to supply the IP address. This can be used to supply the IP address for signature endpoints instead of the signed_by_ip_address parameter. */ xGustoClientIp?: string | undefined; requestBody: PutV1ContractorDocumentSignRequestBody; }; export type PutV1ContractorDocumentSignResponse = { httpMeta: HTTPMetadata; /** * Example response */ documentSigned?: DocumentSigned | undefined; }; /** @internal */ export const PutV1ContractorDocumentSignHeaderXGustoAPIVersion$outboundSchema: z.ZodNativeEnum = z .nativeEnum(PutV1ContractorDocumentSignHeaderXGustoAPIVersion); /** @internal */ export type Fields$Outbound = { key?: string | undefined; value?: string | undefined; }; /** @internal */ export const Fields$outboundSchema: z.ZodType< Fields$Outbound, z.ZodTypeDef, Fields > = z.object({ key: z.string().optional(), value: z.string().optional(), }); export function fieldsToJSON(fields: Fields): string { return JSON.stringify(Fields$outboundSchema.parse(fields)); } /** @internal */ export type PutV1ContractorDocumentSignRequestBody$Outbound = { fields: Array; agree: boolean; signed_by_ip_address?: string | undefined; }; /** @internal */ export const PutV1ContractorDocumentSignRequestBody$outboundSchema: z.ZodType< PutV1ContractorDocumentSignRequestBody$Outbound, z.ZodTypeDef, PutV1ContractorDocumentSignRequestBody > = z.object({ fields: z.array(z.lazy(() => Fields$outboundSchema)), agree: z.boolean(), signedByIpAddress: z.string().optional(), }).transform((v) => { return remap$(v, { signedByIpAddress: "signed_by_ip_address", }); }); export function putV1ContractorDocumentSignRequestBodyToJSON( putV1ContractorDocumentSignRequestBody: PutV1ContractorDocumentSignRequestBody, ): string { return JSON.stringify( PutV1ContractorDocumentSignRequestBody$outboundSchema.parse( putV1ContractorDocumentSignRequestBody, ), ); } /** @internal */ export type PutV1ContractorDocumentSignRequest$Outbound = { "X-Gusto-API-Version": string; document_uuid: string; "x-gusto-client-ip"?: string | undefined; RequestBody: PutV1ContractorDocumentSignRequestBody$Outbound; }; /** @internal */ export const PutV1ContractorDocumentSignRequest$outboundSchema: z.ZodType< PutV1ContractorDocumentSignRequest$Outbound, z.ZodTypeDef, PutV1ContractorDocumentSignRequest > = z.object({ xGustoAPIVersion: PutV1ContractorDocumentSignHeaderXGustoAPIVersion$outboundSchema.default( "2025-06-15", ), documentUuid: z.string(), xGustoClientIp: z.string().optional(), requestBody: z.lazy(() => PutV1ContractorDocumentSignRequestBody$outboundSchema ), }).transform((v) => { return remap$(v, { xGustoAPIVersion: "X-Gusto-API-Version", documentUuid: "document_uuid", xGustoClientIp: "x-gusto-client-ip", requestBody: "RequestBody", }); }); export function putV1ContractorDocumentSignRequestToJSON( putV1ContractorDocumentSignRequest: PutV1ContractorDocumentSignRequest, ): string { return JSON.stringify( PutV1ContractorDocumentSignRequest$outboundSchema.parse( putV1ContractorDocumentSignRequest, ), ); } /** @internal */ export const PutV1ContractorDocumentSignResponse$inboundSchema: z.ZodType< PutV1ContractorDocumentSignResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: HTTPMetadata$inboundSchema, "Document-Signed": DocumentSigned$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "Document-Signed": "documentSigned", }); }); export function putV1ContractorDocumentSignResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PutV1ContractorDocumentSignResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PutV1ContractorDocumentSignResponse' from JSON`, ); }