/*
 * 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 { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import {
  SelectOption,
  SelectOption$inboundSchema,
  SelectOption$Outbound,
  SelectOption$outboundSchema,
} from "../components/selectoption.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * Whether the attribute is on an object or a list.
 */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget = {
  Objects: "objects",
  Lists: "lists",
} as const;
/**
 * Whether the attribute is on an object or a list.
 */
export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget =
  ClosedEnum<
    typeof PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget
  >;

export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionData = {
  /**
   * The Title of the select option
   */
  title?: string | undefined;
  /**
   * Whether or not to archive the select option. See our [archiving guide](/docs/archiving-vs-deleting) for more information on archiving.
   */
  isArchived?: boolean | undefined;
};

export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody =
  {
    data: PatchV2TargetIdentifierAttributesAttributeOptionsOptionData;
  };

export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest = {
  /**
   * Whether the attribute is on an object or a list.
   */
  target: PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget;
  identifier: string;
  attribute: string;
  option: string;
  requestBody:
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody;
};

/**
 * Success
 */
export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse = {
  data: SelectOption;
};

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

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget$outboundSchema:
  z.ZodNativeEnum<
    typeof PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget
  > =
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget$inboundSchema;

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

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$inboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionData,
    z.ZodTypeDef,
    unknown
  > = z.object({
    title: z.string().optional(),
    is_archived: z.boolean().optional(),
  }).transform((v) => {
    return remap$(v, {
      "is_archived": "isArchived",
    });
  });

/** @internal */
export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$Outbound =
  {
    title?: string | undefined;
    is_archived?: boolean | undefined;
  };

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$outboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$Outbound,
    z.ZodTypeDef,
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionData
  > = z.object({
    title: z.string().optional(),
    isArchived: z.boolean().optional(),
  }).transform((v) => {
    return remap$(v, {
      isArchived: "is_archived",
    });
  });

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

export function patchV2TargetIdentifierAttributesAttributeOptionsOptionDataToJSON(
  patchV2TargetIdentifierAttributesAttributeOptionsOptionData:
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionData,
): string {
  return JSON.stringify(
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$outboundSchema
      .parse(patchV2TargetIdentifierAttributesAttributeOptionsOptionData),
  );
}

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

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$inboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody,
    z.ZodTypeDef,
    unknown
  > = z.object({
    data: z.lazy(() =>
      PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$inboundSchema
    ),
  });

/** @internal */
export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$Outbound =
  {
    data: PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$Outbound;
  };

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$outboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$Outbound,
    z.ZodTypeDef,
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody
  > = z.object({
    data: z.lazy(() =>
      PatchV2TargetIdentifierAttributesAttributeOptionsOptionData$outboundSchema
    ),
  });

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

export function patchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBodyToJSON(
  patchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody:
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody,
): string {
  return JSON.stringify(
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$outboundSchema
      .parse(
        patchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody,
      ),
  );
}

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

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$inboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest,
    z.ZodTypeDef,
    unknown
  > = z.object({
    target:
      PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget$inboundSchema,
    identifier: z.string(),
    attribute: z.string(),
    option: z.string(),
    RequestBody: z.lazy(() =>
      PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$inboundSchema
    ),
  }).transform((v) => {
    return remap$(v, {
      "RequestBody": "requestBody",
    });
  });

/** @internal */
export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$Outbound =
  {
    target: string;
    identifier: string;
    attribute: string;
    option: string;
    RequestBody:
      PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$Outbound;
  };

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$outboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$Outbound,
    z.ZodTypeDef,
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest
  > = z.object({
    target:
      PatchV2TargetIdentifierAttributesAttributeOptionsOptionTarget$outboundSchema,
    identifier: z.string(),
    attribute: z.string(),
    option: z.string(),
    requestBody: z.lazy(() =>
      PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequestBody$outboundSchema
    ),
  }).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 PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$ {
  /** @deprecated use `PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$inboundSchema` instead. */
  export const inboundSchema =
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$inboundSchema;
  /** @deprecated use `PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$outboundSchema` instead. */
  export const outboundSchema =
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$outboundSchema;
  /** @deprecated use `PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$Outbound` instead. */
  export type Outbound =
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$Outbound;
}

export function patchV2TargetIdentifierAttributesAttributeOptionsOptionRequestToJSON(
  patchV2TargetIdentifierAttributesAttributeOptionsOptionRequest:
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest,
): string {
  return JSON.stringify(
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest$outboundSchema
      .parse(patchV2TargetIdentifierAttributesAttributeOptionsOptionRequest),
  );
}

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

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse$inboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse,
    z.ZodTypeDef,
    unknown
  > = z.object({
    data: SelectOption$inboundSchema,
  });

/** @internal */
export type PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse$Outbound =
  {
    data: SelectOption$Outbound;
  };

/** @internal */
export const PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse$outboundSchema:
  z.ZodType<
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse$Outbound,
    z.ZodTypeDef,
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse
  > = z.object({
    data: SelectOption$outboundSchema,
  });

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

export function patchV2TargetIdentifierAttributesAttributeOptionsOptionResponseToJSON(
  patchV2TargetIdentifierAttributesAttributeOptionsOptionResponse:
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse,
): string {
  return JSON.stringify(
    PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse$outboundSchema
      .parse(patchV2TargetIdentifierAttributesAttributeOptionsOptionResponse),
  );
}

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