/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { ClosedEnum } from "../types/enums.js";
import * as types from "../types/primitives.js";
import { VercelError } from "./vercelerror.js";

export const ExpectedPriceMismatchCode = {
  ExpectedPriceMismatch: "expected_price_mismatch",
} as const;
export type ExpectedPriceMismatchCode = ClosedEnum<
  typeof ExpectedPriceMismatchCode
>;

/**
 * The expected price passed does not match the actual price.
 */
export type ExpectedPriceMismatchData = {
  status: number;
  code: ExpectedPriceMismatchCode;
  message: string;
};

/**
 * The expected price passed does not match the actual price.
 */
export class ExpectedPriceMismatch extends VercelError {
  status: number;
  code: ExpectedPriceMismatchCode;

  /** The original data that was passed to this error instance. */
  data$: ExpectedPriceMismatchData;

  constructor(
    err: ExpectedPriceMismatchData,
    httpMeta: { response: Response; request: Request; body: string },
  ) {
    const message = err.message || `API error occurred: ${JSON.stringify(err)}`;
    super(message, httpMeta);
    this.data$ = err;
    this.status = err.status;
    this.code = err.code;

    this.name = "ExpectedPriceMismatch";
  }
}

/** @internal */
export const ExpectedPriceMismatchCode$inboundSchema: z.ZodNativeEnum<
  typeof ExpectedPriceMismatchCode
> = z.nativeEnum(ExpectedPriceMismatchCode);

/** @internal */
export const ExpectedPriceMismatch$inboundSchema: z.ZodType<
  ExpectedPriceMismatch,
  z.ZodTypeDef,
  unknown
> = z.object({
  status: types.number(),
  code: ExpectedPriceMismatchCode$inboundSchema,
  message: types.string(),
  request$: z.instanceof(Request),
  response$: z.instanceof(Response),
  body$: z.string(),
})
  .transform((v) => {
    return new ExpectedPriceMismatch(v, {
      request: v.request$,
      response: v.response$,
      body: v.body$,
    });
  });
