/*
 * 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 DomainNotRegisteredCode = {
  DomainNotRegistered: "domain_not_registered",
} as const;
export type DomainNotRegisteredCode = ClosedEnum<
  typeof DomainNotRegisteredCode
>;

/**
 * The domain is not registered with Vercel.
 */
export type DomainNotRegisteredData = {
  status: number;
  code: DomainNotRegisteredCode;
  message: string;
};

/**
 * The domain is not registered with Vercel.
 */
export class DomainNotRegistered extends VercelError {
  status: number;
  code: DomainNotRegisteredCode;

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

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

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

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