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

import * as z from "zod/v4-mini";
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 Pagination = {
  totalCount: number;
  maxPage: number;
};

/** @internal */
export const Pagination$inboundSchema: z.ZodMiniType<Pagination, unknown> = z
  .pipe(
    z.object({
      total_count: z.int(),
      max_page: z.int(),
    }),
    z.transform((v) => {
      return remap$(v, {
        "total_count": "totalCount",
        "max_page": "maxPage",
      });
    }),
  );

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