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

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

export type UpdateDomainRequestBody = {
  /**
   * Name of the domain.
   */
  slug?: string | undefined;
  /**
   * 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;
};

export type UpdateDomainRequest = {
  /**
   * The domain name.
   */
  slug: string;
  requestBody?: UpdateDomainRequestBody | undefined;
};

/** @internal */
export const UpdateDomainRequestBody$inboundSchema: z.ZodType<
  UpdateDomainRequestBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  slug: z.string().optional(),
  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 UpdateDomainRequestBody$Outbound = {
  slug?: string | undefined;
  expiredUrl?: string | null | undefined;
  notFoundUrl?: string | null | undefined;
  archived: boolean;
  placeholder?: string | null | undefined;
  logo?: string | null | undefined;
};

/** @internal */
export const UpdateDomainRequestBody$outboundSchema: z.ZodType<
  UpdateDomainRequestBody$Outbound,
  z.ZodTypeDef,
  UpdateDomainRequestBody
> = z.object({
  slug: z.string().optional(),
  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 UpdateDomainRequestBody$ {
  /** @deprecated use `UpdateDomainRequestBody$inboundSchema` instead. */
  export const inboundSchema = UpdateDomainRequestBody$inboundSchema;
  /** @deprecated use `UpdateDomainRequestBody$outboundSchema` instead. */
  export const outboundSchema = UpdateDomainRequestBody$outboundSchema;
  /** @deprecated use `UpdateDomainRequestBody$Outbound` instead. */
  export type Outbound = UpdateDomainRequestBody$Outbound;
}

export function updateDomainRequestBodyToJSON(
  updateDomainRequestBody: UpdateDomainRequestBody,
): string {
  return JSON.stringify(
    UpdateDomainRequestBody$outboundSchema.parse(updateDomainRequestBody),
  );
}

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

/** @internal */
export const UpdateDomainRequest$inboundSchema: z.ZodType<
  UpdateDomainRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  slug: z.string(),
  RequestBody: z.lazy(() => UpdateDomainRequestBody$inboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    "RequestBody": "requestBody",
  });
});

/** @internal */
export type UpdateDomainRequest$Outbound = {
  slug: string;
  RequestBody?: UpdateDomainRequestBody$Outbound | undefined;
};

/** @internal */
export const UpdateDomainRequest$outboundSchema: z.ZodType<
  UpdateDomainRequest$Outbound,
  z.ZodTypeDef,
  UpdateDomainRequest
> = z.object({
  slug: z.string(),
  requestBody: z.lazy(() => UpdateDomainRequestBody$outboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    requestBody: "RequestBody",
  });
});

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

export function updateDomainRequestToJSON(
  updateDomainRequest: UpdateDomainRequest,
): string {
  return JSON.stringify(
    UpdateDomainRequest$outboundSchema.parse(updateDomainRequest),
  );
}

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