/* * 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 { AddonResponse, AddonResponse$inboundSchema, } from "./addon-response.js"; import { BillingCadence, BillingCadence$inboundSchema, } from "./billing-cadence.js"; import { BillingModel, BillingModel$inboundSchema } from "./billing-model.js"; import { BillingPeriod, BillingPeriod$inboundSchema, } from "./billing-period.js"; import { BillingTier, BillingTier$inboundSchema } from "./billing-tier.js"; import { GroupResponse, GroupResponse$inboundSchema, } from "./group-response.js"; import { InvoiceCadence, InvoiceCadence$inboundSchema, } from "./invoice-cadence.js"; import { MeterResponse, MeterResponse$inboundSchema, } from "./meter-response.js"; import { PlanResponse, PlanResponse$inboundSchema } from "./plan-response.js"; import { PriceEntityType, PriceEntityType$inboundSchema, } from "./price-entity-type.js"; import { PriceFeatureResponse, PriceFeatureResponse$inboundSchema, } from "./price-feature-response.js"; import { PriceJSONBTransformQuantity, PriceJSONBTransformQuantity$inboundSchema, } from "./price-jsonb-transform-quantity.js"; import { PricePriceTier, PricePriceTier$inboundSchema, } from "./price-price-tier.js"; import { PriceType, PriceType$inboundSchema } from "./price-type.js"; import { PriceUnitResponse, PriceUnitResponse$inboundSchema, } from "./price-unit-response.js"; import { PriceUnitType, PriceUnitType$inboundSchema, } from "./price-unit-type.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { Status, Status$inboundSchema } from "./status.js"; export type PriceResponse = { addon?: AddonResponse | undefined; /** * Amount stored in main currency units (e.g., dollars, not cents) * * @remarks * For USD: 12.50 means $12.50 */ amount?: string | undefined; billingCadence?: BillingCadence | undefined; billingModel?: BillingModel | undefined; billingPeriod?: BillingPeriod | undefined; /** * BillingPeriodCount is the count of the billing period ex 1, 3, 6, 12 */ billingPeriodCount?: number | undefined; /** * ConversionRate is the conversion rate of the price unit to the fiat currency */ conversionRate?: string | undefined; createdAt?: Date | undefined; createdBy?: string | undefined; /** * Currency 3 digit ISO currency code in lowercase ex usd, eur, gbp */ currency?: string | undefined; /** * Description of the price */ description?: string | undefined; /** * DisplayAmount is the formatted amount with currency symbol * * @remarks * For USD: $12.50 */ displayAmount?: string | undefined; /** * DisplayName is the name of the price */ displayName?: string | undefined; /** * DisplayPriceUnitAmount is the formatted amount of the price unit */ displayPriceUnitAmount?: string | undefined; /** * EndDate is the end date of the price */ endDate?: Date | undefined; /** * EntityID holds the value of the "entity_id" field. */ entityId?: string | undefined; entityType?: PriceEntityType | undefined; /** * EnvironmentID is the environment identifier for the price */ environmentId?: string | undefined; feature?: PriceFeatureResponse | undefined; group?: GroupResponse | undefined; /** * GroupID references the group this price belongs to */ groupId?: string | undefined; /** * ID uuid identifier for the price */ id?: string | undefined; invoiceCadence?: InvoiceCadence | undefined; /** * LookupKey used for looking up the price in the database */ lookupKey?: string | undefined; metadata?: { [k: string]: string } | undefined; meter?: MeterResponse | undefined; /** * MeterID is the id of the meter for usage based pricing */ meterId?: string | undefined; /** * MinQuantity is the minimum quantity of the price */ minQuantity?: string | null | undefined; /** * ParentPriceID references the root price (always set for price lineage tracking) */ parentPriceId?: string | undefined; plan?: PlanResponse | undefined; /** * PriceUnit is the code of the price unit (e.g., 'btc', 'eth') */ priceUnit?: string | undefined; /** * PriceUnitAmount is the amount of the price unit */ priceUnitAmount?: string | undefined; /** * PriceUnitID is the id of the price unit (for CUSTOM type) */ priceUnitId?: string | undefined; /** * PriceUnitTiers are the tiers for the price unit when BillingModel is TIERED */ priceUnitTiers?: Array | undefined; priceUnitType?: PriceUnitType | undefined; pricingUnit?: PriceUnitResponse | undefined; /** * Sequence is the monotonic stamp bumped on every state change that * * @remarks * subscription line items need to react to. Read by the plan-price sync; * set by the database (DEFAULT nextval) on create and by the price * repository on termination / compatibility-affecting edits. */ sequence?: number | undefined; /** * StartDate is the start date of the price */ startDate?: Date | undefined; status?: Status | undefined; tenantId?: string | undefined; tierMode?: BillingTier | undefined; tiers?: Array | undefined; transformQuantity?: PriceJSONBTransformQuantity | undefined; /** * TrialPeriodDays is the number of days for the trial period * * @remarks * Note: This is only applicable for recurring prices (BILLING_CADENCE_RECURRING) */ trialPeriodDays?: number | undefined; type?: PriceType | undefined; updatedAt?: Date | undefined; updatedBy?: string | undefined; }; /** @internal */ export const PriceResponse$inboundSchema: z.ZodMiniType< PriceResponse, unknown > = z.pipe( z.object({ addon: types.optional(z.lazy(() => AddonResponse$inboundSchema)), amount: types.optional(types.string()), billing_cadence: types.optional(BillingCadence$inboundSchema), billing_model: types.optional(BillingModel$inboundSchema), billing_period: types.optional(BillingPeriod$inboundSchema), billing_period_count: types.optional(types.number()), conversion_rate: types.optional(types.string()), created_at: types.optional(types.date()), created_by: types.optional(types.string()), currency: types.optional(types.string()), description: types.optional(types.string()), display_amount: types.optional(types.string()), display_name: types.optional(types.string()), display_price_unit_amount: types.optional(types.string()), end_date: types.optional(types.date()), entity_id: types.optional(types.string()), entity_type: types.optional(PriceEntityType$inboundSchema), environment_id: types.optional(types.string()), feature: types.optional(PriceFeatureResponse$inboundSchema), group: types.optional(GroupResponse$inboundSchema), group_id: types.optional(types.string()), id: types.optional(types.string()), invoice_cadence: types.optional(InvoiceCadence$inboundSchema), lookup_key: types.optional(types.string()), metadata: types.optional(z.record(z.string(), types.string())), meter: types.optional(MeterResponse$inboundSchema), meter_id: types.optional(types.string()), min_quantity: z.optional(z.nullable(types.string())), parent_price_id: types.optional(types.string()), plan: types.optional(z.lazy(() => PlanResponse$inboundSchema)), price_unit: types.optional(types.string()), price_unit_amount: types.optional(types.string()), price_unit_id: types.optional(types.string()), price_unit_tiers: types.optional(z.array(PricePriceTier$inboundSchema)), price_unit_type: types.optional(PriceUnitType$inboundSchema), pricing_unit: types.optional(PriceUnitResponse$inboundSchema), sequence: types.optional(types.number()), start_date: types.optional(types.date()), status: types.optional(Status$inboundSchema), tenant_id: types.optional(types.string()), tier_mode: types.optional(BillingTier$inboundSchema), tiers: types.optional(z.array(PricePriceTier$inboundSchema)), transform_quantity: types.optional( PriceJSONBTransformQuantity$inboundSchema, ), trial_period_days: types.optional(types.number()), type: types.optional(PriceType$inboundSchema), updated_at: types.optional(types.date()), updated_by: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "billing_cadence": "billingCadence", "billing_model": "billingModel", "billing_period": "billingPeriod", "billing_period_count": "billingPeriodCount", "conversion_rate": "conversionRate", "created_at": "createdAt", "created_by": "createdBy", "display_amount": "displayAmount", "display_name": "displayName", "display_price_unit_amount": "displayPriceUnitAmount", "end_date": "endDate", "entity_id": "entityId", "entity_type": "entityType", "environment_id": "environmentId", "group_id": "groupId", "invoice_cadence": "invoiceCadence", "lookup_key": "lookupKey", "meter_id": "meterId", "min_quantity": "minQuantity", "parent_price_id": "parentPriceId", "price_unit": "priceUnit", "price_unit_amount": "priceUnitAmount", "price_unit_id": "priceUnitId", "price_unit_tiers": "priceUnitTiers", "price_unit_type": "priceUnitType", "pricing_unit": "pricingUnit", "start_date": "startDate", "tenant_id": "tenantId", "tier_mode": "tierMode", "transform_quantity": "transformQuantity", "trial_period_days": "trialPeriodDays", "updated_at": "updatedAt", "updated_by": "updatedBy", }); }), ); export function priceResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PriceResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PriceResponse' from JSON`, ); }