/* * 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 PayrollDigestConflictErrorMetadata = { /** * The UUID of the existing payroll digest batch that already used this idempotency key. */ requestUuid?: string | undefined; }; export type PayrollDigestConflictErrorErrors = { /** * The key identifying the error source. */ errorKey?: string | undefined; /** * The error category. */ category?: string | undefined; /** * Human-readable error message. */ message?: string | undefined; metadata?: PayrollDigestConflictErrorMetadata | undefined; }; /** * Error response when a payroll digest idempotency key has already been used by the same partner. */ export type PayrollDigestConflictErrorData = { errors?: Array | undefined; }; /** * Error response when a payroll digest idempotency key has already been used by the same partner. */ export class PayrollDigestConflictError extends GustoEmbeddedError { errors?: Array | undefined; /** The original data that was passed to this error instance. */ data$: PayrollDigestConflictErrorData; constructor( err: PayrollDigestConflictErrorData, 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 = "PayrollDigestConflictError"; } } /** @internal */ export const PayrollDigestConflictErrorMetadata$inboundSchema: z.ZodType< PayrollDigestConflictErrorMetadata, z.ZodTypeDef, unknown > = z.object({ request_uuid: z.string().optional(), }).transform((v) => { return remap$(v, { "request_uuid": "requestUuid", }); }); export function payrollDigestConflictErrorMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollDigestConflictErrorMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollDigestConflictErrorMetadata' from JSON`, ); } /** @internal */ export const PayrollDigestConflictErrorErrors$inboundSchema: z.ZodType< PayrollDigestConflictErrorErrors, z.ZodTypeDef, unknown > = z.object({ error_key: z.string().optional(), category: z.string().optional(), message: z.string().optional(), metadata: z.lazy(() => PayrollDigestConflictErrorMetadata$inboundSchema) .optional(), }).transform((v) => { return remap$(v, { "error_key": "errorKey", }); }); export function payrollDigestConflictErrorErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollDigestConflictErrorErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollDigestConflictErrorErrors' from JSON`, ); } /** @internal */ export const PayrollDigestConflictError$inboundSchema: z.ZodType< PayrollDigestConflictError, z.ZodTypeDef, unknown > = z.object({ errors: z.array(z.lazy(() => PayrollDigestConflictErrorErrors$inboundSchema)) .optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new PayrollDigestConflictError(v, { request: v.request$, response: v.response$, body: v.body$, }); });