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

import * as z from "zod/v3";
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 PaginationInfo = {
  totalItems: number;
  totalPages: number;
  currentPage: number;
  pageSize: number;
  hasMore: boolean;
};

/** @internal */
export const PaginationInfo$inboundSchema: z.ZodType<
  PaginationInfo,
  z.ZodTypeDef,
  unknown
> = z.object({
  total_items: z.number().int(),
  total_pages: z.number().int(),
  current_page: z.number().int(),
  page_size: z.number().int(),
  has_more: z.boolean(),
}).transform((v) => {
  return remap$(v, {
    "total_items": "totalItems",
    "total_pages": "totalPages",
    "current_page": "currentPage",
    "page_size": "pageSize",
    "has_more": "hasMore",
  });
});

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