/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { InkeepAnalyticsError } from "./inkeepanalyticserror.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 InkeepAnalyticsError {
    constructor(err, httpMeta) {
        const message = err.error?.message
            || `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        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 */
export const ForbiddenErrorCode$inboundSchema = z.nativeEnum(ForbiddenErrorCode);
/** @internal */
export const ForbiddenErrorCode$outboundSchema = ForbiddenErrorCode$inboundSchema;
/** @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(),
});
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),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    return new Forbidden(v, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @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),
}));
//# sourceMappingURL=forbidden.js.map