/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { GustoEmbeddedError } from "./gustoembeddederror.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type Metadata = { /** * The UUID of the existing payroll cancellation batch that already used this idempotency key. */ requestUuid?: string | undefined; }; export type PayrollBatchConflictErrorErrors = { /** * The key identifying the error source. */ errorKey?: string | undefined; /** * The error category. */ category?: string | undefined; /** * Human-readable error message. */ message?: string | undefined; metadata?: Metadata | undefined; }; /** * Error response when a payroll cancellation idempotency key has already been used by the same partner. */ export type PayrollBatchConflictErrorData = { errors?: Array | undefined; }; /** * Error response when a payroll cancellation idempotency key has already been used by the same partner. */ export class PayrollBatchConflictError extends GustoEmbeddedError { errors?: Array | undefined; /** The original data that was passed to this error instance. */ data$: PayrollBatchConflictErrorData; constructor( err: PayrollBatchConflictErrorData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; if (err.errors != null) this.errors = err.errors; this.name = "PayrollBatchConflictError"; } } /** @internal */ export const Metadata$inboundSchema: z.ZodType< Metadata, z.ZodTypeDef, unknown > = z.object({ request_uuid: z.string().optional(), }).transform((v) => { return remap$(v, { "request_uuid": "requestUuid", }); }); export function metadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Metadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Metadata' from JSON`, ); } /** @internal */ export const PayrollBatchConflictErrorErrors$inboundSchema: z.ZodType< PayrollBatchConflictErrorErrors, z.ZodTypeDef, unknown > = z.object({ error_key: z.string().optional(), category: z.string().optional(), message: z.string().optional(), metadata: z.lazy(() => Metadata$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "error_key": "errorKey", }); }); export function payrollBatchConflictErrorErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollBatchConflictErrorErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollBatchConflictErrorErrors' from JSON`, ); } /** @internal */ export const PayrollBatchConflictError$inboundSchema: z.ZodType< PayrollBatchConflictError, z.ZodTypeDef, unknown > = z.object({ errors: z.array(z.lazy(() => PayrollBatchConflictErrorErrors$inboundSchema)) .optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new PayrollBatchConflictError(v, { request: v.request$, response: v.response$, body: v.body$, }); });