/*
 * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { Identity, Identity$inboundSchema } from "./identity.js";
import { Meta, Meta$inboundSchema } from "./meta.js";
import { Pagination, Pagination$inboundSchema } from "./pagination.js";

export type V2IdentitiesListIdentitiesResponseBody = {
  /**
   * Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The `requestId` is particularly important when troubleshooting issues with the Unkey support team.
   */
  meta: Meta;
  /**
   * List of identities matching the specified criteria.
   */
  data: Array<Identity>;
  /**
   * Pagination metadata for list endpoints. Provides information necessary to traverse through large result sets efficiently using cursor-based pagination.
   */
  pagination: Pagination;
};

/** @internal */
export const V2IdentitiesListIdentitiesResponseBody$inboundSchema: z.ZodType<
  V2IdentitiesListIdentitiesResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  meta: Meta$inboundSchema,
  data: z.array(Identity$inboundSchema),
  pagination: Pagination$inboundSchema,
});

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