"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnprocessableEntityResponseError$ = exports.UnprocessableEntityResponseError$outboundSchema = exports.UnprocessableEntityResponseError$inboundSchema = exports.UnprocessableEntityResponseImsxCodeMinor$ = exports.UnprocessableEntityResponseImsxCodeMinor$outboundSchema = exports.UnprocessableEntityResponseImsxCodeMinor$inboundSchema = exports.UnprocessableEntityResponseImsxCodeMinorField$ = exports.UnprocessableEntityResponseImsxCodeMinorField$outboundSchema = exports.UnprocessableEntityResponseImsxCodeMinorField$inboundSchema = exports.UnprocessableEntityResponseError = void 0;
exports.unprocessableEntityResponseImsxCodeMinorFieldToJSON = unprocessableEntityResponseImsxCodeMinorFieldToJSON;
exports.unprocessableEntityResponseImsxCodeMinorFieldFromJSON = unprocessableEntityResponseImsxCodeMinorFieldFromJSON;
exports.unprocessableEntityResponseImsxCodeMinorToJSON = unprocessableEntityResponseImsxCodeMinorToJSON;
exports.unprocessableEntityResponseImsxCodeMinorFromJSON = unprocessableEntityResponseImsxCodeMinorFromJSON;
const z = __importStar(require("zod"));
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const powerpatherror_js_1 = require("./powerpatherror.js");
class UnprocessableEntityResponseError extends powerpatherror_js_1.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 = "UnprocessableEntityResponseError";
    }
}
exports.UnprocessableEntityResponseError = UnprocessableEntityResponseError;
/** @internal */
exports.UnprocessableEntityResponseImsxCodeMinorField$inboundSchema = z.object({
    imsx_codeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem").optional(),
    imsx_codeMinorFieldValue: z.literal("invaliddata").default("invaliddata")
        .optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "imsx_codeMinorFieldName": "imsxCodeMinorFieldName",
        "imsx_codeMinorFieldValue": "imsxCodeMinorFieldValue",
    });
});
/** @internal */
exports.UnprocessableEntityResponseImsxCodeMinorField$outboundSchema = z.object({
    imsxCodeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem"),
    imsxCodeMinorFieldValue: z.literal("invaliddata").default("invaliddata"),
}).transform((v) => {
    return (0, primitives_js_1.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.
 */
var UnprocessableEntityResponseImsxCodeMinorField$;
(function (UnprocessableEntityResponseImsxCodeMinorField$) {
    /** @deprecated use `UnprocessableEntityResponseImsxCodeMinorField$inboundSchema` instead. */
    UnprocessableEntityResponseImsxCodeMinorField$.inboundSchema = exports.UnprocessableEntityResponseImsxCodeMinorField$inboundSchema;
    /** @deprecated use `UnprocessableEntityResponseImsxCodeMinorField$outboundSchema` instead. */
    UnprocessableEntityResponseImsxCodeMinorField$.outboundSchema = exports.UnprocessableEntityResponseImsxCodeMinorField$outboundSchema;
})(UnprocessableEntityResponseImsxCodeMinorField$ || (exports.UnprocessableEntityResponseImsxCodeMinorField$ = UnprocessableEntityResponseImsxCodeMinorField$ = {}));
function unprocessableEntityResponseImsxCodeMinorFieldToJSON(unprocessableEntityResponseImsxCodeMinorField) {
    return JSON.stringify(exports.UnprocessableEntityResponseImsxCodeMinorField$outboundSchema.parse(unprocessableEntityResponseImsxCodeMinorField));
}
function unprocessableEntityResponseImsxCodeMinorFieldFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.UnprocessableEntityResponseImsxCodeMinorField$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UnprocessableEntityResponseImsxCodeMinorField' from JSON`);
}
/** @internal */
exports.UnprocessableEntityResponseImsxCodeMinor$inboundSchema = z.object({
    imsx_codeMinorField: z.array(z.lazy(() => exports.UnprocessableEntityResponseImsxCodeMinorField$inboundSchema)),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "imsx_codeMinorField": "imsxCodeMinorField",
    });
});
/** @internal */
exports.UnprocessableEntityResponseImsxCodeMinor$outboundSchema = z.object({
    imsxCodeMinorField: z.array(z.lazy(() => exports.UnprocessableEntityResponseImsxCodeMinorField$outboundSchema)),
}).transform((v) => {
    return (0, primitives_js_1.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.
 */
var UnprocessableEntityResponseImsxCodeMinor$;
(function (UnprocessableEntityResponseImsxCodeMinor$) {
    /** @deprecated use `UnprocessableEntityResponseImsxCodeMinor$inboundSchema` instead. */
    UnprocessableEntityResponseImsxCodeMinor$.inboundSchema = exports.UnprocessableEntityResponseImsxCodeMinor$inboundSchema;
    /** @deprecated use `UnprocessableEntityResponseImsxCodeMinor$outboundSchema` instead. */
    UnprocessableEntityResponseImsxCodeMinor$.outboundSchema = exports.UnprocessableEntityResponseImsxCodeMinor$outboundSchema;
})(UnprocessableEntityResponseImsxCodeMinor$ || (exports.UnprocessableEntityResponseImsxCodeMinor$ = UnprocessableEntityResponseImsxCodeMinor$ = {}));
function unprocessableEntityResponseImsxCodeMinorToJSON(unprocessableEntityResponseImsxCodeMinor) {
    return JSON.stringify(exports.UnprocessableEntityResponseImsxCodeMinor$outboundSchema.parse(unprocessableEntityResponseImsxCodeMinor));
}
function unprocessableEntityResponseImsxCodeMinorFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.UnprocessableEntityResponseImsxCodeMinor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UnprocessableEntityResponseImsxCodeMinor' from JSON`);
}
/** @internal */
exports.UnprocessableEntityResponseError$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(() => exports.UnprocessableEntityResponseImsxCodeMinor$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 = (0, primitives_js_1.remap)(v, {
        "imsx_codeMajor": "imsxCodeMajor",
        "imsx_severity": "imsxSeverity",
        "imsx_description": "imsxDescription",
        "imsx_CodeMinor": "imsxCodeMinor",
        "imsx_error_details": "imsxErrorDetails",
    });
    return new UnprocessableEntityResponseError(remapped, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
exports.UnprocessableEntityResponseError$outboundSchema = z.instanceof(UnprocessableEntityResponseError)
    .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(() => exports.UnprocessableEntityResponseImsxCodeMinor$outboundSchema),
    imsxErrorDetails: z.array(z.record(z.string())).optional(),
}).transform((v) => {
    return (0, primitives_js_1.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.
 */
var UnprocessableEntityResponseError$;
(function (UnprocessableEntityResponseError$) {
    /** @deprecated use `UnprocessableEntityResponseError$inboundSchema` instead. */
    UnprocessableEntityResponseError$.inboundSchema = exports.UnprocessableEntityResponseError$inboundSchema;
    /** @deprecated use `UnprocessableEntityResponseError$outboundSchema` instead. */
    UnprocessableEntityResponseError$.outboundSchema = exports.UnprocessableEntityResponseError$outboundSchema;
})(UnprocessableEntityResponseError$ || (exports.UnprocessableEntityResponseError$ = UnprocessableEntityResponseError$ = {}));
//# sourceMappingURL=unprocessableentityresponseerror.js.map