/*
 * 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 OCRUsageInfo = {
  /**
   * Number of pages processed
   */
  pagesProcessed: number;
  /**
   * Document size in bytes
   */
  docSizeBytes?: number | null | undefined;
};

/** @internal */
export const OCRUsageInfo$inboundSchema: z.ZodType<
  OCRUsageInfo,
  z.ZodTypeDef,
  unknown
> = z.object({
  pages_processed: z.number().int(),
  doc_size_bytes: z.nullable(z.number().int()).optional(),
}).transform((v) => {
  return remap$(v, {
    "pages_processed": "pagesProcessed",
    "doc_size_bytes": "docSizeBytes",
  });
});

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