/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import * as types from "../../types/primitives.js"; import * as models from "../index.js"; import { SDKError } from "./sdk-error.js"; export type PaymentRequiredErrorData = { x402Version: 2; error?: string | undefined; resource: models.PaymentRequiredResource; accepts: Array; extensions?: { [k: string]: any } | null | undefined; }; export class PaymentRequiredError extends SDKError { x402Version: 2; error?: string | undefined; resource: models.PaymentRequiredResource; accepts: Array; extensions?: { [k: string]: any } | null | undefined; /** The original data that was passed to this error instance. */ data$: PaymentRequiredErrorData; constructor( err: PaymentRequiredErrorData, 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.x402Version = err.x402Version; if (err.error != null) this.error = err.error; this.resource = err.resource; this.accepts = err.accepts; if (err.extensions != null) this.extensions = err.extensions; this.name = "PaymentRequiredError"; } } /** @internal */ export const PaymentRequiredError$inboundSchema: z.ZodMiniType< PaymentRequiredError, unknown > = z.pipe( z.object({ x402Version: types.literal(2), error: types.optional(types.string()), resource: z.lazy(() => models.PaymentRequiredResource$inboundSchema), accepts: z.array(models.PaymentRequirements$inboundSchema), extensions: z.optional(z.nullable(z.record(z.string(), z.any()))), request$: z.custom(x => x instanceof Request), response$: z.custom(x => x instanceof Response), body$: z.string(), }), z.transform((v) => { return new PaymentRequiredError(v, { request: v.request$, response: v.response$, body: v.body$, }); }), );