/*
 * 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 UnauthorizedRequestResponseError 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 = "UnauthorizedRequestResponseError";
    }
}
/** @internal */
export const UnauthorizedRequestResponseImsxCodeMinorField$inboundSchema = z.object({
    imsx_codeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem").optional(),
    imsx_codeMinorFieldValue: z.literal("unauthorisedrequest").default("unauthorisedrequest").optional(),
}).transform((v) => {
    return remap$(v, {
        "imsx_codeMinorFieldName": "imsxCodeMinorFieldName",
        "imsx_codeMinorFieldValue": "imsxCodeMinorFieldValue",
    });
});
/** @internal */
export const UnauthorizedRequestResponseImsxCodeMinorField$outboundSchema = z.object({
    imsxCodeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem"),
    imsxCodeMinorFieldValue: z.literal("unauthorisedrequest").default("unauthorisedrequest"),
}).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 UnauthorizedRequestResponseImsxCodeMinorField$;
(function (UnauthorizedRequestResponseImsxCodeMinorField$) {
    /** @deprecated use `UnauthorizedRequestResponseImsxCodeMinorField$inboundSchema` instead. */
    UnauthorizedRequestResponseImsxCodeMinorField$.inboundSchema = UnauthorizedRequestResponseImsxCodeMinorField$inboundSchema;
    /** @deprecated use `UnauthorizedRequestResponseImsxCodeMinorField$outboundSchema` instead. */
    UnauthorizedRequestResponseImsxCodeMinorField$.outboundSchema = UnauthorizedRequestResponseImsxCodeMinorField$outboundSchema;
})(UnauthorizedRequestResponseImsxCodeMinorField$ || (UnauthorizedRequestResponseImsxCodeMinorField$ = {}));
export function unauthorizedRequestResponseImsxCodeMinorFieldToJSON(unauthorizedRequestResponseImsxCodeMinorField) {
    return JSON.stringify(UnauthorizedRequestResponseImsxCodeMinorField$outboundSchema.parse(unauthorizedRequestResponseImsxCodeMinorField));
}
export function unauthorizedRequestResponseImsxCodeMinorFieldFromJSON(jsonString) {
    return safeParse(jsonString, (x) => UnauthorizedRequestResponseImsxCodeMinorField$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UnauthorizedRequestResponseImsxCodeMinorField' from JSON`);
}
/** @internal */
export const UnauthorizedRequestResponseImsxCodeMinor$inboundSchema = z.object({
    imsx_codeMinorField: z.array(z.lazy(() => UnauthorizedRequestResponseImsxCodeMinorField$inboundSchema)),
}).transform((v) => {
    return remap$(v, {
        "imsx_codeMinorField": "imsxCodeMinorField",
    });
});
/** @internal */
export const UnauthorizedRequestResponseImsxCodeMinor$outboundSchema = z.object({
    imsxCodeMinorField: z.array(z.lazy(() => UnauthorizedRequestResponseImsxCodeMinorField$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 UnauthorizedRequestResponseImsxCodeMinor$;
(function (UnauthorizedRequestResponseImsxCodeMinor$) {
    /** @deprecated use `UnauthorizedRequestResponseImsxCodeMinor$inboundSchema` instead. */
    UnauthorizedRequestResponseImsxCodeMinor$.inboundSchema = UnauthorizedRequestResponseImsxCodeMinor$inboundSchema;
    /** @deprecated use `UnauthorizedRequestResponseImsxCodeMinor$outboundSchema` instead. */
    UnauthorizedRequestResponseImsxCodeMinor$.outboundSchema = UnauthorizedRequestResponseImsxCodeMinor$outboundSchema;
})(UnauthorizedRequestResponseImsxCodeMinor$ || (UnauthorizedRequestResponseImsxCodeMinor$ = {}));
export function unauthorizedRequestResponseImsxCodeMinorToJSON(unauthorizedRequestResponseImsxCodeMinor) {
    return JSON.stringify(UnauthorizedRequestResponseImsxCodeMinor$outboundSchema.parse(unauthorizedRequestResponseImsxCodeMinor));
}
export function unauthorizedRequestResponseImsxCodeMinorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => UnauthorizedRequestResponseImsxCodeMinor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UnauthorizedRequestResponseImsxCodeMinor' from JSON`);
}
/** @internal */
export const UnauthorizedRequestResponseError$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(() => UnauthorizedRequestResponseImsxCodeMinor$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 UnauthorizedRequestResponseError(remapped, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const UnauthorizedRequestResponseError$outboundSchema = z.instanceof(UnauthorizedRequestResponseError)
    .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(() => UnauthorizedRequestResponseImsxCodeMinor$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 UnauthorizedRequestResponseError$;
(function (UnauthorizedRequestResponseError$) {
    /** @deprecated use `UnauthorizedRequestResponseError$inboundSchema` instead. */
    UnauthorizedRequestResponseError$.inboundSchema = UnauthorizedRequestResponseError$inboundSchema;
    /** @deprecated use `UnauthorizedRequestResponseError$outboundSchema` instead. */
    UnauthorizedRequestResponseError$.outboundSchema = UnauthorizedRequestResponseError$outboundSchema;
})(UnauthorizedRequestResponseError$ || (UnauthorizedRequestResponseError$ = {}));
//# sourceMappingURL=unauthorizedrequestresponseerror.js.map