/* * 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 { smartUnion } from "../../types/smartUnion.js"; import { PresentmentCurrency, PresentmentCurrency$outboundSchema, } from "./presentmentcurrency.js"; import { TaxBehaviorOption, TaxBehaviorOption$outboundSchema, } from "./taxbehavioroption.js"; /** * The price per unit in cents. Supports up to 12 decimal places. */ export type UnitAmount = number | string; /** * Schema to create a metered price with a fixed unit price. */ export type ProductPriceMeteredUnitCreate = { amountType: "metered_unit"; priceCurrency?: PresentmentCurrency | undefined; /** * The tax behavior of the price. If not set, it will default to the organization's default tax behavior. */ taxBehavior?: TaxBehaviorOption | null | undefined; /** * The ID of the meter associated to the price. */ meterId: string; /** * The price per unit in cents. Supports up to 12 decimal places. */ unitAmount: number | string; /** * Optional maximum amount in cents that can be charged, regardless of the number of units consumed. */ capAmount?: number | null | undefined; }; /** @internal */ export type UnitAmount$Outbound = number | string; /** @internal */ export const UnitAmount$outboundSchema: z.ZodMiniType< UnitAmount$Outbound, UnitAmount > = smartUnion([z.number(), z.string()]); export function unitAmountToJSON(unitAmount: UnitAmount): string { return JSON.stringify(UnitAmount$outboundSchema.parse(unitAmount)); } /** @internal */ export type ProductPriceMeteredUnitCreate$Outbound = { amount_type: "metered_unit"; price_currency?: string | undefined; tax_behavior?: string | null | undefined; meter_id: string; unit_amount: number | string; cap_amount?: number | null | undefined; }; /** @internal */ export const ProductPriceMeteredUnitCreate$outboundSchema: z.ZodMiniType< ProductPriceMeteredUnitCreate$Outbound, ProductPriceMeteredUnitCreate > = z.pipe( z.object({ amountType: z.literal("metered_unit"), priceCurrency: z.optional(PresentmentCurrency$outboundSchema), taxBehavior: z.optional(z.nullable(TaxBehaviorOption$outboundSchema)), meterId: z.string(), unitAmount: smartUnion([z.number(), z.string()]), capAmount: z.optional(z.nullable(z.int())), }), z.transform((v) => { return remap$(v, { amountType: "amount_type", priceCurrency: "price_currency", taxBehavior: "tax_behavior", meterId: "meter_id", unitAmount: "unit_amount", capAmount: "cap_amount", }); }), ); export function productPriceMeteredUnitCreateToJSON( productPriceMeteredUnitCreate: ProductPriceMeteredUnitCreate, ): string { return JSON.stringify( ProductPriceMeteredUnitCreate$outboundSchema.parse( productPriceMeteredUnitCreate, ), ); }