/*
 * 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 TooManyRequestsResponseError 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 = "TooManyRequestsResponseError";
    }
}
/** @internal */
export const TooManyRequestsResponseImsxCodeMinorField$inboundSchema = z.object({
    imsx_codeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem").optional(),
    imsx_codeMinorFieldValue: z.literal("server_busy").default("server_busy")
        .optional(),
}).transform((v) => {
    return remap$(v, {
        "imsx_codeMinorFieldName": "imsxCodeMinorFieldName",
        "imsx_codeMinorFieldValue": "imsxCodeMinorFieldValue",
    });
});
/** @internal */
export const TooManyRequestsResponseImsxCodeMinorField$outboundSchema = z.object({
    imsxCodeMinorFieldName: z.literal("TargetEndSystem").default("TargetEndSystem"),
    imsxCodeMinorFieldValue: z.literal("server_busy").default("server_busy"),
}).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 TooManyRequestsResponseImsxCodeMinorField$;
(function (TooManyRequestsResponseImsxCodeMinorField$) {
    /** @deprecated use `TooManyRequestsResponseImsxCodeMinorField$inboundSchema` instead. */
    TooManyRequestsResponseImsxCodeMinorField$.inboundSchema = TooManyRequestsResponseImsxCodeMinorField$inboundSchema;
    /** @deprecated use `TooManyRequestsResponseImsxCodeMinorField$outboundSchema` instead. */
    TooManyRequestsResponseImsxCodeMinorField$.outboundSchema = TooManyRequestsResponseImsxCodeMinorField$outboundSchema;
})(TooManyRequestsResponseImsxCodeMinorField$ || (TooManyRequestsResponseImsxCodeMinorField$ = {}));
export function tooManyRequestsResponseImsxCodeMinorFieldToJSON(tooManyRequestsResponseImsxCodeMinorField) {
    return JSON.stringify(TooManyRequestsResponseImsxCodeMinorField$outboundSchema.parse(tooManyRequestsResponseImsxCodeMinorField));
}
export function tooManyRequestsResponseImsxCodeMinorFieldFromJSON(jsonString) {
    return safeParse(jsonString, (x) => TooManyRequestsResponseImsxCodeMinorField$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TooManyRequestsResponseImsxCodeMinorField' from JSON`);
}
/** @internal */
export const TooManyRequestsResponseImsxCodeMinor$inboundSchema = z.object({
    imsx_codeMinorField: z.array(z.lazy(() => TooManyRequestsResponseImsxCodeMinorField$inboundSchema)),
}).transform((v) => {
    return remap$(v, {
        "imsx_codeMinorField": "imsxCodeMinorField",
    });
});
/** @internal */
export const TooManyRequestsResponseImsxCodeMinor$outboundSchema = z.object({
    imsxCodeMinorField: z.array(z.lazy(() => TooManyRequestsResponseImsxCodeMinorField$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 TooManyRequestsResponseImsxCodeMinor$;
(function (TooManyRequestsResponseImsxCodeMinor$) {
    /** @deprecated use `TooManyRequestsResponseImsxCodeMinor$inboundSchema` instead. */
    TooManyRequestsResponseImsxCodeMinor$.inboundSchema = TooManyRequestsResponseImsxCodeMinor$inboundSchema;
    /** @deprecated use `TooManyRequestsResponseImsxCodeMinor$outboundSchema` instead. */
    TooManyRequestsResponseImsxCodeMinor$.outboundSchema = TooManyRequestsResponseImsxCodeMinor$outboundSchema;
})(TooManyRequestsResponseImsxCodeMinor$ || (TooManyRequestsResponseImsxCodeMinor$ = {}));
export function tooManyRequestsResponseImsxCodeMinorToJSON(tooManyRequestsResponseImsxCodeMinor) {
    return JSON.stringify(TooManyRequestsResponseImsxCodeMinor$outboundSchema.parse(tooManyRequestsResponseImsxCodeMinor));
}
export function tooManyRequestsResponseImsxCodeMinorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => TooManyRequestsResponseImsxCodeMinor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TooManyRequestsResponseImsxCodeMinor' from JSON`);
}
/** @internal */
export const TooManyRequestsResponseError$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(() => TooManyRequestsResponseImsxCodeMinor$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 TooManyRequestsResponseError(remapped, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const TooManyRequestsResponseError$outboundSchema = z.instanceof(TooManyRequestsResponseError)
    .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(() => TooManyRequestsResponseImsxCodeMinor$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 TooManyRequestsResponseError$;
(function (TooManyRequestsResponseError$) {
    /** @deprecated use `TooManyRequestsResponseError$inboundSchema` instead. */
    TooManyRequestsResponseError$.inboundSchema = TooManyRequestsResponseError$inboundSchema;
    /** @deprecated use `TooManyRequestsResponseError$outboundSchema` instead. */
    TooManyRequestsResponseError$.outboundSchema = TooManyRequestsResponseError$outboundSchema;
})(TooManyRequestsResponseError$ || (TooManyRequestsResponseError$ = {}));
//# sourceMappingURL=toomanyrequestsresponseerror.js.map