/*
 * 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 InternalServerErrorCode = {
    InternalServerError: "internal_server_error",
};
/**
 * A short code indicating the error code returned.
 */
export const InternalServerErrorErrorCode = {
    InternalServerError: "internal_server_error",
};
export class InternalServerError 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 = "InternalServerError";
    }
}
/** @internal */
export const InternalServerErrorCode$inboundSchema = z.nativeEnum(InternalServerErrorCode);
/** @internal */
export const InternalServerErrorCode$outboundSchema = InternalServerErrorCode$inboundSchema;
/** @internal */
export const InternalServerErrorErrorCode$inboundSchema = z.nativeEnum(InternalServerErrorErrorCode);
/** @internal */
export const InternalServerErrorErrorCode$outboundSchema = InternalServerErrorErrorCode$inboundSchema;
/** @internal */
export const InternalServerErrorError$inboundSchema = z.object({
    code: InternalServerErrorErrorCode$inboundSchema,
    message: z.string(),
});
/** @internal */
export const InternalServerErrorError$outboundSchema = z.object({
    code: InternalServerErrorErrorCode$outboundSchema,
    message: z.string(),
});
export function internalServerErrorErrorToJSON(internalServerErrorError) {
    return JSON.stringify(InternalServerErrorError$outboundSchema.parse(internalServerErrorError));
}
export function internalServerErrorErrorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => InternalServerErrorError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InternalServerErrorError' from JSON`);
}
/** @internal */
export const InternalServerError$inboundSchema = z.object({
    title: z.string(),
    status: z.number(),
    detail: z.string(),
    instance: z.string().optional(),
    requestId: z.string().optional(),
    code: InternalServerErrorCode$inboundSchema,
    error: z.lazy(() => InternalServerErrorError$inboundSchema),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    return new InternalServerError(v, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const InternalServerError$outboundSchema = z.instanceof(InternalServerError)
    .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: InternalServerErrorCode$outboundSchema,
    error: z.lazy(() => InternalServerErrorError$outboundSchema),
}));
//# sourceMappingURL=internalservererror.js.map