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

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type VerifyProjectDomainRequest = {
  /**
   * The unique project identifier or the project name
   */
  idOrName: string;
  /**
   * The domain name you want to verify
   */
  domain: string;
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
};

/**
 * The project domain was verified successfully
 *
 * @remarks
 * Domain is already verified
 */
export type VerifyProjectDomainResponseBody = {
  name: string;
  apexName: string;
  projectId: string;
  redirect?: string | null | undefined;
  redirectStatusCode?: number | null | undefined;
  gitBranch?: string | null | undefined;
  customEnvironmentId?: string | null | undefined;
  updatedAt?: number | undefined;
  createdAt?: number | undefined;
  /**
   * `true` if the domain is verified for use with the project. If `false` it will not be used as an alias on this project until the challenge in `verification` is completed.
   */
  verified: boolean;
};

/** @internal */
export type VerifyProjectDomainRequest$Outbound = {
  idOrName: string;
  domain: string;
  teamId?: string | undefined;
  slug?: string | undefined;
};

/** @internal */
export const VerifyProjectDomainRequest$outboundSchema: z.ZodType<
  VerifyProjectDomainRequest$Outbound,
  z.ZodTypeDef,
  VerifyProjectDomainRequest
> = z.object({
  idOrName: z.string(),
  domain: z.string(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
});

export function verifyProjectDomainRequestToJSON(
  verifyProjectDomainRequest: VerifyProjectDomainRequest,
): string {
  return JSON.stringify(
    VerifyProjectDomainRequest$outboundSchema.parse(verifyProjectDomainRequest),
  );
}

/** @internal */
export const VerifyProjectDomainResponseBody$inboundSchema: z.ZodType<
  VerifyProjectDomainResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  name: types.string(),
  apexName: types.string(),
  projectId: types.string(),
  redirect: z.nullable(types.string()).optional(),
  redirectStatusCode: z.nullable(types.number()).optional(),
  gitBranch: z.nullable(types.string()).optional(),
  customEnvironmentId: z.nullable(types.string()).optional(),
  updatedAt: types.optional(types.number()),
  createdAt: types.optional(types.number()),
  verified: types.boolean(),
});

export function verifyProjectDomainResponseBodyFromJSON(
  jsonString: string,
): SafeParseResult<VerifyProjectDomainResponseBody, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => VerifyProjectDomainResponseBody$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'VerifyProjectDomainResponseBody' from JSON`,
  );
}
