/* * 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 * as types from "../../types/primitives.js"; import { Addon, Addon$inboundSchema } from "./addon.js"; import { AggregationType, AggregationType$inboundSchema, } from "./aggregation-type.js"; import { BucketSummary, BucketSummary$inboundSchema, } from "./bucket-summary.js"; import { CommitmentInfo, CommitmentInfo$inboundSchema, } from "./commitment-info.js"; import { Feature, Feature$inboundSchema } from "./feature.js"; import { GroupGroup, GroupGroup$inboundSchema } from "./group-group.js"; import { MeterMeter, MeterMeter$inboundSchema } from "./meter-meter.js"; import { Plan, Plan$inboundSchema } from "./plan.js"; import { PriceResponse, PriceResponse$inboundSchema, } from "./price-response.js"; import { ReportingUnit, ReportingUnit$inboundSchema, } from "./reporting-unit.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { SubscriptionSubscriptionLineItem, SubscriptionSubscriptionLineItem$inboundSchema, } from "./subscription-subscription-line-item.js"; import { UsageAnalyticPoint, UsageAnalyticPoint$inboundSchema, } from "./usage-analytic-point.js"; import { WindowSize, WindowSize$inboundSchema } from "./window-size.js"; export type UsageAnalyticItem = { addOnId?: string | undefined; addon?: Addon | undefined; aggregationType?: AggregationType | undefined; /** * BucketSummaries is populated only when BreakdownBucket=true. Contains one * * @remarks * entry per defined CommitmentTimeBucket plus one for out-of-bucket usage. */ bucketSummaries?: Array | undefined; commitmentInfo?: CommitmentInfo | undefined; currency?: string | undefined; /** * Number of events that contributed to this aggregation */ eventCount?: number | undefined; eventName?: string | undefined; feature?: Feature | undefined; featureId?: string | undefined; group?: GroupGroup | undefined; meter?: MeterMeter | undefined; /** * Meter ID */ meterId?: string | undefined; name?: string | undefined; plan?: Plan | undefined; planId?: string | undefined; points?: Array | undefined; price?: PriceResponse | undefined; /** * Price ID used for this usage */ priceId?: string | undefined; /** * Stores property values for flexible grouping (e.g., org_id -> "org123") */ properties?: { [k: string]: string } | undefined; reportingUnit?: ReportingUnit | undefined; source?: string | undefined; /** * List of sources when not grouping by source */ sources?: Array | undefined; /** * Subscription line item ID */ subLineItemId?: string | undefined; /** * Subscription ID */ subscriptionId?: string | undefined; subscriptionLineItem?: SubscriptionSubscriptionLineItem | undefined; subtotal?: string | undefined; /** * TotalCost is the final cost after discount (Subtotal - TotalDiscount) */ totalCost?: string | undefined; totalDiscount?: string | undefined; totalUsage?: string | undefined; /** * Empty string when feature has no reporting unit; otherwise the value in reporting units */ totalUsageDisplay?: string | undefined; unit?: string | undefined; unitPlural?: string | undefined; windowSize?: WindowSize | undefined; }; /** @internal */ export const UsageAnalyticItem$inboundSchema: z.ZodMiniType< UsageAnalyticItem, unknown > = z.pipe( z.object({ add_on_id: types.optional(types.string()), addon: types.optional(Addon$inboundSchema), aggregation_type: types.optional(AggregationType$inboundSchema), bucket_summaries: types.optional(z.array(BucketSummary$inboundSchema)), commitment_info: types.optional(CommitmentInfo$inboundSchema), currency: types.optional(types.string()), event_count: types.optional(types.number()), event_name: types.optional(types.string()), feature: types.optional(Feature$inboundSchema), feature_id: types.optional(types.string()), group: types.optional(GroupGroup$inboundSchema), meter: types.optional(MeterMeter$inboundSchema), meter_id: types.optional(types.string()), name: types.optional(types.string()), plan: types.optional(Plan$inboundSchema), plan_id: types.optional(types.string()), points: types.optional(z.array(UsageAnalyticPoint$inboundSchema)), price: types.optional(PriceResponse$inboundSchema), price_id: types.optional(types.string()), properties: types.optional(z.record(z.string(), types.string())), reporting_unit: types.optional(ReportingUnit$inboundSchema), source: types.optional(types.string()), sources: types.optional(z.array(types.string())), sub_line_item_id: types.optional(types.string()), subscription_id: types.optional(types.string()), subscription_line_item: types.optional( SubscriptionSubscriptionLineItem$inboundSchema, ), subtotal: types.optional(types.string()), total_cost: types.optional(types.string()), total_discount: types.optional(types.string()), total_usage: types.optional(types.string()), total_usage_display: types.optional(types.string()), unit: types.optional(types.string()), unit_plural: types.optional(types.string()), window_size: types.optional(WindowSize$inboundSchema), }), z.transform((v) => { return remap$(v, { "add_on_id": "addOnId", "aggregation_type": "aggregationType", "bucket_summaries": "bucketSummaries", "commitment_info": "commitmentInfo", "event_count": "eventCount", "event_name": "eventName", "feature_id": "featureId", "meter_id": "meterId", "plan_id": "planId", "price_id": "priceId", "reporting_unit": "reportingUnit", "sub_line_item_id": "subLineItemId", "subscription_id": "subscriptionId", "subscription_line_item": "subscriptionLineItem", "total_cost": "totalCost", "total_discount": "totalDiscount", "total_usage": "totalUsage", "total_usage_display": "totalUsageDisplay", "unit_plural": "unitPlural", "window_size": "windowSize", }); }), ); export function usageAnalyticItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UsageAnalyticItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UsageAnalyticItem' from JSON`, ); }