/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import * as components from "../components/index.js";
import { CloudinaryAnalysisError } from "./cloudinaryanalysiserror.js";
/**
 * Rate limited
 */
export class RateLimitedResponse extends CloudinaryAnalysisError {
    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;
        if (err.error != null)
            this.error = err.error;
        if (err.limits != null)
            this.limits = err.limits;
        this.name = "RateLimitedResponse";
    }
}
/** @internal */
export const RateLimitedResponse$inboundSchema = z.object({
    error: z.nullable(components.ErrorObject$inboundSchema).optional(),
    limits: z.nullable(components.LimitsObject$inboundSchema).optional(),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    return new RateLimitedResponse(v, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const RateLimitedResponse$outboundSchema = z.instanceof(RateLimitedResponse)
    .transform(v => v.data$)
    .pipe(z.object({
    error: z.nullable(components.ErrorObject$outboundSchema).optional(),
    limits: z.nullable(components.LimitsObject$outboundSchema).optional(),
}));
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var RateLimitedResponse$;
(function (RateLimitedResponse$) {
    /** @deprecated use `RateLimitedResponse$inboundSchema` instead. */
    RateLimitedResponse$.inboundSchema = RateLimitedResponse$inboundSchema;
    /** @deprecated use `RateLimitedResponse$outboundSchema` instead. */
    RateLimitedResponse$.outboundSchema = RateLimitedResponse$outboundSchema;
})(RateLimitedResponse$ || (RateLimitedResponse$ = {}));
//# sourceMappingURL=ratelimitedresponse.js.map