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

import * as z from "zod/v4-mini";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { MeterQuantity, MeterQuantity$inboundSchema } from "./meterquantity.js";

export type MeterQuantities = {
  quantities: Array<MeterQuantity>;
  /**
   * The total quantity for the period.
   */
  total: number;
};

/** @internal */
export const MeterQuantities$inboundSchema: z.ZodMiniType<
  MeterQuantities,
  unknown
> = z.object({
  quantities: z.array(MeterQuantity$inboundSchema),
  total: z.number(),
});

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