/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
/**
 * A short code indicating the error code returned.
 */
export const ForbiddenCode = {
    Forbidden: "forbidden",
};
/**
 * A short code indicating the error code returned.
 */
export const ForbiddenErrorCode = {
    Forbidden: "forbidden",
};
export class Forbidden extends Error {
    constructor(err) {
        const message = "message" in err && typeof err.message === "string"
            ? err.message
            : `API error occurred: ${JSON.stringify(err)}`;
        super(message);
        this.data$ = err;
        this.title = err.title;
        this.status = err.status;
        this.detail = err.detail;
        if (err.instance != null)
            this.instance = err.instance;
        if (err.requestId != null)
            this.requestId = err.requestId;
        this.code = err.code;
        this.error = err.error;
        this.name = "Forbidden";
    }
}
/** @internal */
export const ForbiddenCode$inboundSchema = z.nativeEnum(ForbiddenCode);
/** @internal */
export const ForbiddenCode$outboundSchema = ForbiddenCode$inboundSchema;
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ForbiddenCode$;
(function (ForbiddenCode$) {
    /** @deprecated use `ForbiddenCode$inboundSchema` instead. */
    ForbiddenCode$.inboundSchema = ForbiddenCode$inboundSchema;
    /** @deprecated use `ForbiddenCode$outboundSchema` instead. */
    ForbiddenCode$.outboundSchema = ForbiddenCode$outboundSchema;
})(ForbiddenCode$ || (ForbiddenCode$ = {}));
/** @internal */
export const ForbiddenErrorCode$inboundSchema = z.nativeEnum(ForbiddenErrorCode);
/** @internal */
export const ForbiddenErrorCode$outboundSchema = ForbiddenErrorCode$inboundSchema;
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ForbiddenErrorCode$;
(function (ForbiddenErrorCode$) {
    /** @deprecated use `ForbiddenErrorCode$inboundSchema` instead. */
    ForbiddenErrorCode$.inboundSchema = ForbiddenErrorCode$inboundSchema;
    /** @deprecated use `ForbiddenErrorCode$outboundSchema` instead. */
    ForbiddenErrorCode$.outboundSchema = ForbiddenErrorCode$outboundSchema;
})(ForbiddenErrorCode$ || (ForbiddenErrorCode$ = {}));
/** @internal */
export const ForbiddenError$inboundSchema = z.object({
    code: ForbiddenErrorCode$inboundSchema,
    message: z.string(),
});
/** @internal */
export const ForbiddenError$outboundSchema = z.object({
    code: ForbiddenErrorCode$outboundSchema,
    message: z.string(),
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ForbiddenError$;
(function (ForbiddenError$) {
    /** @deprecated use `ForbiddenError$inboundSchema` instead. */
    ForbiddenError$.inboundSchema = ForbiddenError$inboundSchema;
    /** @deprecated use `ForbiddenError$outboundSchema` instead. */
    ForbiddenError$.outboundSchema = ForbiddenError$outboundSchema;
})(ForbiddenError$ || (ForbiddenError$ = {}));
export function forbiddenErrorToJSON(forbiddenError) {
    return JSON.stringify(ForbiddenError$outboundSchema.parse(forbiddenError));
}
export function forbiddenErrorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => ForbiddenError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ForbiddenError' from JSON`);
}
/** @internal */
export const Forbidden$inboundSchema = z.object({
    title: z.string(),
    status: z.number(),
    detail: z.string(),
    instance: z.string().optional(),
    requestId: z.string().optional(),
    code: ForbiddenCode$inboundSchema,
    error: z.lazy(() => ForbiddenError$inboundSchema),
})
    .transform((v) => {
    return new Forbidden(v);
});
/** @internal */
export const Forbidden$outboundSchema = z.instanceof(Forbidden)
    .transform(v => v.data$)
    .pipe(z.object({
    title: z.string(),
    status: z.number(),
    detail: z.string(),
    instance: z.string().optional(),
    requestId: z.string().optional(),
    code: ForbiddenCode$outboundSchema,
    error: z.lazy(() => ForbiddenError$outboundSchema),
}));
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var Forbidden$;
(function (Forbidden$) {
    /** @deprecated use `Forbidden$inboundSchema` instead. */
    Forbidden$.inboundSchema = Forbidden$inboundSchema;
    /** @deprecated use `Forbidden$outboundSchema` instead. */
    Forbidden$.outboundSchema = Forbidden$outboundSchema;
})(Forbidden$ || (Forbidden$ = {}));
//# sourceMappingURL=forbidden.js.map