/*
 * 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 {
  Attribute,
  Attribute$inboundSchema,
  Attribute$Outbound,
  Attribute$outboundSchema,
} from "../components/attribute.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

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

export type GetV2TargetIdentifierAttributesRequest = {
  /**
   * Whether the attributes are on an object or a list.
   */
  target: GetV2TargetIdentifierAttributesTarget;
  identifier: string;
  limit?: number | undefined;
  offset?: number | undefined;
  showArchived?: boolean | undefined;
};

/**
 * Success
 */
export type GetV2TargetIdentifierAttributesResponse = {
  data: Array<Attribute>;
};

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

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

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

/** @internal */
export const GetV2TargetIdentifierAttributesRequest$inboundSchema: z.ZodType<
  GetV2TargetIdentifierAttributesRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  target: GetV2TargetIdentifierAttributesTarget$inboundSchema,
  identifier: z.string(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
  show_archived: z.boolean().optional(),
}).transform((v) => {
  return remap$(v, {
    "show_archived": "showArchived",
  });
});

/** @internal */
export type GetV2TargetIdentifierAttributesRequest$Outbound = {
  target: string;
  identifier: string;
  limit?: number | undefined;
  offset?: number | undefined;
  show_archived?: boolean | undefined;
};

/** @internal */
export const GetV2TargetIdentifierAttributesRequest$outboundSchema: z.ZodType<
  GetV2TargetIdentifierAttributesRequest$Outbound,
  z.ZodTypeDef,
  GetV2TargetIdentifierAttributesRequest
> = z.object({
  target: GetV2TargetIdentifierAttributesTarget$outboundSchema,
  identifier: z.string(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
  showArchived: z.boolean().optional(),
}).transform((v) => {
  return remap$(v, {
    showArchived: "show_archived",
  });
});

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

export function getV2TargetIdentifierAttributesRequestToJSON(
  getV2TargetIdentifierAttributesRequest:
    GetV2TargetIdentifierAttributesRequest,
): string {
  return JSON.stringify(
    GetV2TargetIdentifierAttributesRequest$outboundSchema.parse(
      getV2TargetIdentifierAttributesRequest,
    ),
  );
}

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

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

/** @internal */
export type GetV2TargetIdentifierAttributesResponse$Outbound = {
  data: Array<Attribute$Outbound>;
};

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

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

export function getV2TargetIdentifierAttributesResponseToJSON(
  getV2TargetIdentifierAttributesResponse:
    GetV2TargetIdentifierAttributesResponse,
): string {
  return JSON.stringify(
    GetV2TargetIdentifierAttributesResponse$outboundSchema.parse(
      getV2TargetIdentifierAttributesResponse,
    ),
  );
}

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