/* * 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 = { /** * A categorization of the payroll blocker, e.g. "geocode_error" */ key?: string | undefined; }; export type PayrollBlockersErrorErrors = { /** * The string "base" */ errorKey?: string | undefined; /** * The string "payroll_blocker" */ category?: string | undefined; /** * Human readable description of the payroll blocker */ message?: string | undefined; metadata?: Metadata | undefined; }; /** * Payroll Blockers Error * * @remarks * * For detailed information, see the [Payroll Blockers guide](https://docs.gusto.com/embedded-payroll/docs/payroll-blockers) */ export type PayrollBlockersErrorData = { errors?: Array | undefined; }; /** * Payroll Blockers Error * * @remarks * * For detailed information, see the [Payroll Blockers guide](https://docs.gusto.com/embedded-payroll/docs/payroll-blockers) */ export class PayrollBlockersError extends GustoEmbeddedError { errors?: Array | undefined; /** The original data that was passed to this error instance. */ data$: PayrollBlockersErrorData; constructor( err: PayrollBlockersErrorData, 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 = "PayrollBlockersError"; } } /** @internal */ export const Metadata$inboundSchema: z.ZodType< Metadata, z.ZodTypeDef, unknown > = z.object({ key: z.string().optional(), }); 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 PayrollBlockersErrorErrors$inboundSchema: z.ZodType< PayrollBlockersErrorErrors, 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 payrollBlockersErrorErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PayrollBlockersErrorErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PayrollBlockersErrorErrors' from JSON`, ); } /** @internal */ export const PayrollBlockersError$inboundSchema: z.ZodType< PayrollBlockersError, z.ZodTypeDef, unknown > = z.object({ errors: z.array(z.lazy(() => PayrollBlockersErrorErrors$inboundSchema)) .optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new PayrollBlockersError(v, { request: v.request$, response: v.response$, body: v.body$, }); });