/* * 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 ConflictErrorObjectErrors = { /** * Specifies where the error occurs. Typically this key identifies the attribute/parameter related to the error. */ errorKey: string; /** * Specifies the type of error. The category provides error groupings and can be used to build custom error handling in your integration. */ category: string; /** * Provides details about the error - generally this message can be surfaced to an end user. */ message?: string | undefined; }; /** * Conflict * * @remarks * * This error occurs when the resource version provided does not match the current version. Retrieve the latest version and retry. */ export type ConflictErrorObjectData = { errors: Array; }; /** * Conflict * * @remarks * * This error occurs when the resource version provided does not match the current version. Retrieve the latest version and retry. */ export class ConflictErrorObject extends GustoEmbeddedError { errors: Array; /** The original data that was passed to this error instance. */ data$: ConflictErrorObjectData; constructor( err: ConflictErrorObjectData, 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; this.errors = err.errors; this.name = "ConflictErrorObject"; } } /** @internal */ export const ConflictErrorObjectErrors$inboundSchema: z.ZodType< ConflictErrorObjectErrors, z.ZodTypeDef, unknown > = z.object({ error_key: z.string(), category: z.string(), message: z.string().optional(), }).transform((v) => { return remap$(v, { "error_key": "errorKey", }); }); export function conflictErrorObjectErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ConflictErrorObjectErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConflictErrorObjectErrors' from JSON`, ); } /** @internal */ export const ConflictErrorObject$inboundSchema: z.ZodType< ConflictErrorObject, z.ZodTypeDef, unknown > = z.object({ errors: z.array(z.lazy(() => ConflictErrorObjectErrors$inboundSchema)), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new ConflictErrorObject(v, { request: v.request$, response: v.response$, body: v.body$, }); });