/*
 * 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 BoughtTooRecentlyCode = {
  BoughtTooRecently: "bought_too_recently",
} as const;
export type BoughtTooRecentlyCode = ClosedEnum<typeof BoughtTooRecentlyCode>;

/**
 * The domain was bought too recently to determine verification status.
 */
export type BoughtTooRecentlyData = {
  status: number;
  code: BoughtTooRecentlyCode;
  message: string;
};

/**
 * The domain was bought too recently to determine verification status.
 */
export class BoughtTooRecently extends VercelError {
  status: number;
  code: BoughtTooRecentlyCode;

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

  constructor(
    err: BoughtTooRecentlyData,
    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 = "BoughtTooRecently";
  }
}

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

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