/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import * as models from "../index.js"; import { SupertoneError } from "./supertoneerror.js"; export type UnauthorizedErrorResponseData = { /** * Response status */ status: string; /** * Unauthorized error details */ message: models.UnauthorizedErrorResponseMessage; }; export class UnauthorizedErrorResponse extends SupertoneError { /** * Response status */ status: string; /** The original data that was passed to this error instance. */ data$: UnauthorizedErrorResponseData; constructor( err: UnauthorizedErrorResponseData, 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.status = err.status; this.name = "UnauthorizedErrorResponse"; } } /** @internal */ export const UnauthorizedErrorResponse$inboundSchema: z.ZodType< UnauthorizedErrorResponse, z.ZodTypeDef, unknown > = z.object({ status: z.string(), message: z.lazy(() => models.UnauthorizedErrorResponseMessage$inboundSchema), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new UnauthorizedErrorResponse(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type UnauthorizedErrorResponse$Outbound = { status: string; message: models.UnauthorizedErrorResponseMessage$Outbound; }; /** @internal */ export const UnauthorizedErrorResponse$outboundSchema: z.ZodType< UnauthorizedErrorResponse$Outbound, z.ZodTypeDef, UnauthorizedErrorResponse > = z.instanceof(UnauthorizedErrorResponse) .transform(v => v.data$) .pipe(z.object({ status: z.string(), message: z.lazy(() => models.UnauthorizedErrorResponseMessage$outboundSchema ), })); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UnauthorizedErrorResponse$ { /** @deprecated use `UnauthorizedErrorResponse$inboundSchema` instead. */ export const inboundSchema = UnauthorizedErrorResponse$inboundSchema; /** @deprecated use `UnauthorizedErrorResponse$outboundSchema` instead. */ export const outboundSchema = UnauthorizedErrorResponse$outboundSchema; /** @deprecated use `UnauthorizedErrorResponse$Outbound` instead. */ export type Outbound = UnauthorizedErrorResponse$Outbound; }