/* * 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 { HTTPMetadata, HTTPMetadata$inboundSchema, } from "../components/httpmetadata.js"; import { PayrollBatch, PayrollBatch$inboundSchema, } from "../components/payrollbatch.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type PostV1PayrollBatchesSecurity = { systemAccessAuth: string; }; /** * 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 PostV1PayrollBatchesHeaderXGustoAPIVersion = { 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 PostV1PayrollBatchesHeaderXGustoAPIVersion = ClosedEnum< typeof PostV1PayrollBatchesHeaderXGustoAPIVersion >; /** * The action to perform on the batch. Only `cancel` is supported. */ export const BatchAction = { Cancel: "cancel", } as const; /** * The action to perform on the batch. Only `cancel` is supported. */ export type BatchAction = ClosedEnum; /** * The type of entity to act on. */ export const EntityType = { Payroll: "payroll", } as const; /** * The type of entity to act on. */ export type EntityType = ClosedEnum; export type Batch = { /** * The type of entity to act on. */ entityType: EntityType; /** * The UUID of the payroll to cancel. Payrolls the partner is not authorized to access, or that do not exist, appear in the response's `exclusions` array. */ uuid: string; /** * The UUID of the company that owns the payroll. The partner must be mapped to this company. */ companyUuid: string; }; export type PostV1PayrollBatchesRequestBody = { /** * A partner-generated unique identifier to ensure idempotency of the batch request. Scoped per partner. */ idempotencyKey: string; /** * The action to perform on the batch. Only `cancel` is supported. */ batchAction: BatchAction; /** * Array of payrolls to cancel. Maximum 100 payrolls per request. */ batch: Array; }; export type PostV1PayrollBatchesRequest = { /** * 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?: PostV1PayrollBatchesHeaderXGustoAPIVersion | undefined; requestBody: PostV1PayrollBatchesRequestBody; }; export type PostV1PayrollBatchesResponse = { httpMeta: HTTPMetadata; /** * created */ payrollBatch?: PayrollBatch | undefined; }; /** @internal */ export type PostV1PayrollBatchesSecurity$Outbound = { SystemAccessAuth: string; }; /** @internal */ export const PostV1PayrollBatchesSecurity$outboundSchema: z.ZodType< PostV1PayrollBatchesSecurity$Outbound, z.ZodTypeDef, PostV1PayrollBatchesSecurity > = z.object({ systemAccessAuth: z.string(), }).transform((v) => { return remap$(v, { systemAccessAuth: "SystemAccessAuth", }); }); export function postV1PayrollBatchesSecurityToJSON( postV1PayrollBatchesSecurity: PostV1PayrollBatchesSecurity, ): string { return JSON.stringify( PostV1PayrollBatchesSecurity$outboundSchema.parse( postV1PayrollBatchesSecurity, ), ); } /** @internal */ export const PostV1PayrollBatchesHeaderXGustoAPIVersion$outboundSchema: z.ZodNativeEnum = z .nativeEnum(PostV1PayrollBatchesHeaderXGustoAPIVersion); /** @internal */ export const BatchAction$outboundSchema: z.ZodNativeEnum = z .nativeEnum(BatchAction); /** @internal */ export const EntityType$outboundSchema: z.ZodNativeEnum = z .nativeEnum(EntityType); /** @internal */ export type Batch$Outbound = { entity_type: string; uuid: string; company_uuid: string; }; /** @internal */ export const Batch$outboundSchema: z.ZodType< Batch$Outbound, z.ZodTypeDef, Batch > = z.object({ entityType: EntityType$outboundSchema, uuid: z.string(), companyUuid: z.string(), }).transform((v) => { return remap$(v, { entityType: "entity_type", companyUuid: "company_uuid", }); }); export function batchToJSON(batch: Batch): string { return JSON.stringify(Batch$outboundSchema.parse(batch)); } /** @internal */ export type PostV1PayrollBatchesRequestBody$Outbound = { idempotency_key: string; batch_action: string; batch: Array; }; /** @internal */ export const PostV1PayrollBatchesRequestBody$outboundSchema: z.ZodType< PostV1PayrollBatchesRequestBody$Outbound, z.ZodTypeDef, PostV1PayrollBatchesRequestBody > = z.object({ idempotencyKey: z.string(), batchAction: BatchAction$outboundSchema, batch: z.array(z.lazy(() => Batch$outboundSchema)), }).transform((v) => { return remap$(v, { idempotencyKey: "idempotency_key", batchAction: "batch_action", }); }); export function postV1PayrollBatchesRequestBodyToJSON( postV1PayrollBatchesRequestBody: PostV1PayrollBatchesRequestBody, ): string { return JSON.stringify( PostV1PayrollBatchesRequestBody$outboundSchema.parse( postV1PayrollBatchesRequestBody, ), ); } /** @internal */ export type PostV1PayrollBatchesRequest$Outbound = { "X-Gusto-API-Version": string; RequestBody: PostV1PayrollBatchesRequestBody$Outbound; }; /** @internal */ export const PostV1PayrollBatchesRequest$outboundSchema: z.ZodType< PostV1PayrollBatchesRequest$Outbound, z.ZodTypeDef, PostV1PayrollBatchesRequest > = z.object({ xGustoAPIVersion: PostV1PayrollBatchesHeaderXGustoAPIVersion$outboundSchema .default("2025-06-15"), requestBody: z.lazy(() => PostV1PayrollBatchesRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { xGustoAPIVersion: "X-Gusto-API-Version", requestBody: "RequestBody", }); }); export function postV1PayrollBatchesRequestToJSON( postV1PayrollBatchesRequest: PostV1PayrollBatchesRequest, ): string { return JSON.stringify( PostV1PayrollBatchesRequest$outboundSchema.parse( postV1PayrollBatchesRequest, ), ); } /** @internal */ export const PostV1PayrollBatchesResponse$inboundSchema: z.ZodType< PostV1PayrollBatchesResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: HTTPMetadata$inboundSchema, "Payroll-Batch": PayrollBatch$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "Payroll-Batch": "payrollBatch", }); }); export function postV1PayrollBatchesResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PostV1PayrollBatchesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PostV1PayrollBatchesResponse' from JSON`, ); }