/* * 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"; import { Customer, Customer$inboundSchema } from "./customer.js"; import { Meter, Meter$inboundSchema } from "./meter.js"; /** * An active customer meter, with current consumed and credited units. */ export type CustomerMeter = { /** * The ID of the object. */ id: string; /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; /** * The ID of the customer. */ customerId: string; /** * The ID of the meter. */ meterId: string; /** * The number of consumed units. */ consumedUnits: number; /** * The number of credited units. */ creditedUnits: number; /** * The balance of the meter, i.e. the difference between credited and consumed units. */ balance: number; customer: Customer; meter: Meter; }; /** @internal */ export const CustomerMeter$inboundSchema: z.ZodMiniType< CustomerMeter, unknown > = z.pipe( z.object({ id: z.string(), created_at: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), modified_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), customer_id: z.string(), meter_id: z.string(), consumed_units: z.number(), credited_units: z.int(), balance: z.number(), customer: Customer$inboundSchema, meter: Meter$inboundSchema, }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "customer_id": "customerId", "meter_id": "meterId", "consumed_units": "consumedUnits", "credited_units": "creditedUnits", }); }), ); export function customerMeterFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomerMeter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomerMeter' from JSON`, ); }