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

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

export type CreateDomainRequestBody = {
  /**
   * Name of the domain.
   */
  slug: string;
  /**
   * Redirect users to a specific URL when any link under this domain has expired.
   */
  expiredUrl?: string | null | undefined;
  /**
   * Redirect users to a specific URL when a link under this domain doesn't exist.
   */
  notFoundUrl?: string | null | undefined;
  /**
   * Whether to archive this domain. `false` will unarchive a previously archived domain.
   */
  archived?: boolean | undefined;
  /**
   * Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.
   */
  placeholder?: string | null | undefined;
  /**
   * The logo of the domain.
   */
  logo?: string | null | undefined;
};

/** @internal */
export const CreateDomainRequestBody$inboundSchema: z.ZodType<
  CreateDomainRequestBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  slug: z.string(),
  expiredUrl: z.nullable(z.string()).optional(),
  notFoundUrl: z.nullable(z.string()).optional(),
  archived: z.boolean().default(false),
  placeholder: z.nullable(z.string()).optional(),
  logo: z.nullable(z.string()).optional(),
});

/** @internal */
export type CreateDomainRequestBody$Outbound = {
  slug: string;
  expiredUrl?: string | null | undefined;
  notFoundUrl?: string | null | undefined;
  archived: boolean;
  placeholder?: string | null | undefined;
  logo?: string | null | undefined;
};

/** @internal */
export const CreateDomainRequestBody$outboundSchema: z.ZodType<
  CreateDomainRequestBody$Outbound,
  z.ZodTypeDef,
  CreateDomainRequestBody
> = z.object({
  slug: z.string(),
  expiredUrl: z.nullable(z.string()).optional(),
  notFoundUrl: z.nullable(z.string()).optional(),
  archived: z.boolean().default(false),
  placeholder: z.nullable(z.string()).optional(),
  logo: z.nullable(z.string()).optional(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace CreateDomainRequestBody$ {
  /** @deprecated use `CreateDomainRequestBody$inboundSchema` instead. */
  export const inboundSchema = CreateDomainRequestBody$inboundSchema;
  /** @deprecated use `CreateDomainRequestBody$outboundSchema` instead. */
  export const outboundSchema = CreateDomainRequestBody$outboundSchema;
  /** @deprecated use `CreateDomainRequestBody$Outbound` instead. */
  export type Outbound = CreateDomainRequestBody$Outbound;
}

export function createDomainRequestBodyToJSON(
  createDomainRequestBody: CreateDomainRequestBody,
): string {
  return JSON.stringify(
    CreateDomainRequestBody$outboundSchema.parse(createDomainRequestBody),
  );
}

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