/* * 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 { collectExtraKeys as collectExtraKeys$ } from "../../lib/schemas.js"; import { OutpostError } from "./outposterror.js"; /** * A collection of codes that generally means the client was not authenticated correctly for the request they want to make */ export type UnauthorizedErrorData = { message?: string | undefined; additionalProperties: { [k: string]: any }; }; /** * A collection of codes that generally means the client was not authenticated correctly for the request they want to make */ export class UnauthorizedError extends OutpostError { additionalProperties: { [k: string]: any } = {}; /** The original data that was passed to this error instance. */ data$: UnauthorizedErrorData; constructor( err: UnauthorizedErrorData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = err.message || `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; if (err.additionalProperties != null) { this.additionalProperties = err.additionalProperties; } this.name = "UnauthorizedError"; } } /** @internal */ export const UnauthorizedError$inboundSchema: z.ZodType< UnauthorizedError, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ message: z.string().optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .catchall(z.any()), "additionalProperties", false, ) .transform((v) => { return new UnauthorizedError(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type UnauthorizedError$Outbound = { message?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const UnauthorizedError$outboundSchema: z.ZodType< UnauthorizedError$Outbound, z.ZodTypeDef, UnauthorizedError > = z.instanceof(UnauthorizedError) .transform(v => v.data$) .pipe( z.object({ message: z.string().optional(), additionalProperties: z.record(z.any()), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { additionalProperties: null, }), }; }), );