/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { PowerPathError } from "./powerpatherror.js";
export class BadRequestResponseError extends PowerPathError {
    constructor(err, httpMeta) {
        const message = "message" in err && typeof err.message === "string"
            ? err.message
            : `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        this.data$ = err;
        this.imsxCodeMajor = err.imsxCodeMajor;
        this.imsxSeverity = err.imsxSeverity;
        this.imsxDescription = err.imsxDescription;
        this.imsxCodeMinor = err.imsxCodeMinor;
        if (err.imsxErrorDetails != null) {
            this.imsxErrorDetails = err.imsxErrorDetails;
        }
        this.name = "BadRequestResponseError";
    }
}
/** @internal */
export const BadRequestResponseImsxCodeMinorField$inboundSchema = z.object({
    imsx_codeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem").optional(),
    imsx_codeMinorFieldValue: z.literal("invaliddata").default("invaliddata")
        .optional(),
}).transform((v) => {
    return remap$(v, {
        "imsx_codeMinorFieldName": "imsxCodeMinorFieldName",
        "imsx_codeMinorFieldValue": "imsxCodeMinorFieldValue",
    });
});
/** @internal */
export const BadRequestResponseImsxCodeMinorField$outboundSchema = z.object({
    imsxCodeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem"),
    imsxCodeMinorFieldValue: z.literal("invaliddata").default("invaliddata"),
}).transform((v) => {
    return remap$(v, {
        imsxCodeMinorFieldName: "imsx_codeMinorFieldName",
        imsxCodeMinorFieldValue: "imsx_codeMinorFieldValue",
    });
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var BadRequestResponseImsxCodeMinorField$;
(function (BadRequestResponseImsxCodeMinorField$) {
    /** @deprecated use `BadRequestResponseImsxCodeMinorField$inboundSchema` instead. */
    BadRequestResponseImsxCodeMinorField$.inboundSchema = BadRequestResponseImsxCodeMinorField$inboundSchema;
    /** @deprecated use `BadRequestResponseImsxCodeMinorField$outboundSchema` instead. */
    BadRequestResponseImsxCodeMinorField$.outboundSchema = BadRequestResponseImsxCodeMinorField$outboundSchema;
})(BadRequestResponseImsxCodeMinorField$ || (BadRequestResponseImsxCodeMinorField$ = {}));
export function badRequestResponseImsxCodeMinorFieldToJSON(badRequestResponseImsxCodeMinorField) {
    return JSON.stringify(BadRequestResponseImsxCodeMinorField$outboundSchema.parse(badRequestResponseImsxCodeMinorField));
}
export function badRequestResponseImsxCodeMinorFieldFromJSON(jsonString) {
    return safeParse(jsonString, (x) => BadRequestResponseImsxCodeMinorField$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BadRequestResponseImsxCodeMinorField' from JSON`);
}
/** @internal */
export const BadRequestResponseImsxCodeMinor$inboundSchema = z.object({
    imsx_codeMinorField: z.array(z.lazy(() => BadRequestResponseImsxCodeMinorField$inboundSchema)),
}).transform((v) => {
    return remap$(v, {
        "imsx_codeMinorField": "imsxCodeMinorField",
    });
});
/** @internal */
export const BadRequestResponseImsxCodeMinor$outboundSchema = z.object({
    imsxCodeMinorField: z.array(z.lazy(() => BadRequestResponseImsxCodeMinorField$outboundSchema)),
}).transform((v) => {
    return remap$(v, {
        imsxCodeMinorField: "imsx_codeMinorField",
    });
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var BadRequestResponseImsxCodeMinor$;
(function (BadRequestResponseImsxCodeMinor$) {
    /** @deprecated use `BadRequestResponseImsxCodeMinor$inboundSchema` instead. */
    BadRequestResponseImsxCodeMinor$.inboundSchema = BadRequestResponseImsxCodeMinor$inboundSchema;
    /** @deprecated use `BadRequestResponseImsxCodeMinor$outboundSchema` instead. */
    BadRequestResponseImsxCodeMinor$.outboundSchema = BadRequestResponseImsxCodeMinor$outboundSchema;
})(BadRequestResponseImsxCodeMinor$ || (BadRequestResponseImsxCodeMinor$ = {}));
export function badRequestResponseImsxCodeMinorToJSON(badRequestResponseImsxCodeMinor) {
    return JSON.stringify(BadRequestResponseImsxCodeMinor$outboundSchema.parse(badRequestResponseImsxCodeMinor));
}
export function badRequestResponseImsxCodeMinorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => BadRequestResponseImsxCodeMinor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BadRequestResponseImsxCodeMinor' from JSON`);
}
/** @internal */
export const BadRequestResponseError$inboundSchema = z.object({
    imsx_codeMajor: z.literal("failure").default("failure"),
    imsx_severity: z.literal("error").default("error"),
    imsx_description: z.string(),
    imsx_CodeMinor: z.lazy(() => BadRequestResponseImsxCodeMinor$inboundSchema),
    imsx_error_details: z.array(z.record(z.string())).optional(),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    const remapped = remap$(v, {
        "imsx_codeMajor": "imsxCodeMajor",
        "imsx_severity": "imsxSeverity",
        "imsx_description": "imsxDescription",
        "imsx_CodeMinor": "imsxCodeMinor",
        "imsx_error_details": "imsxErrorDetails",
    });
    return new BadRequestResponseError(remapped, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const BadRequestResponseError$outboundSchema = z.instanceof(BadRequestResponseError)
    .transform(v => v.data$)
    .pipe(z.object({
    imsxCodeMajor: z.literal("failure").default("failure"),
    imsxSeverity: z.literal("error").default("error"),
    imsxDescription: z.string(),
    imsxCodeMinor: z.lazy(() => BadRequestResponseImsxCodeMinor$outboundSchema),
    imsxErrorDetails: z.array(z.record(z.string())).optional(),
}).transform((v) => {
    return remap$(v, {
        imsxCodeMajor: "imsx_codeMajor",
        imsxSeverity: "imsx_severity",
        imsxDescription: "imsx_description",
        imsxCodeMinor: "imsx_CodeMinor",
        imsxErrorDetails: "imsx_error_details",
    });
}));
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var BadRequestResponseError$;
(function (BadRequestResponseError$) {
    /** @deprecated use `BadRequestResponseError$inboundSchema` instead. */
    BadRequestResponseError$.inboundSchema = BadRequestResponseError$inboundSchema;
    /** @deprecated use `BadRequestResponseError$outboundSchema` instead. */
    BadRequestResponseError$.outboundSchema = BadRequestResponseError$outboundSchema;
})(BadRequestResponseError$ || (BadRequestResponseError$ = {}));
//# sourceMappingURL=badrequestresponseerror.js.map