/*
 * 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * This object contains information related to the pagination of the current request, including the necessary parameters to get the next or previous page of data.
 */
export type Pagination = {
  /**
   * Amount of items in the current page.
   */
  count: number;
  /**
   * Timestamp that must be used to request the next page.
   */
  next: number | null;
  /**
   * Timestamp that must be used to request the previous page.
   */
  prev: number | null;
};

/** @internal */
export const Pagination$inboundSchema: z.ZodType<
  Pagination,
  z.ZodTypeDef,
  unknown
> = z.object({
  count: types.number(),
  next: types.nullable(types.number()),
  prev: types.nullable(types.number()),
});

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