/*
 * 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 TldNotSupportedCode = {
  TldNotSupported: "tld_not_supported",
} as const;
export type TldNotSupportedCode = ClosedEnum<typeof TldNotSupportedCode>;

/**
 * The TLD is not currently supported.
 */
export type TldNotSupportedData = {
  status: number;
  code: TldNotSupportedCode;
  message: string;
};

/**
 * The TLD is not currently supported.
 */
export class TldNotSupported extends VercelError {
  status: number;
  code: TldNotSupportedCode;

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

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

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

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