/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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 { EnvironmentMode, EnvironmentMode$inboundSchema, EnvironmentMode$outboundSchema, } from "./environmentmode.js"; export type SubscriptionItemEntity = { /** * Unique identifier for the object. */ id: string; /** * String representing the environment. */ mode: EnvironmentMode; /** * String representing the object’s type. Objects of the same type share the same value. */ object: string; /** * The ID of the product associated with the subscription item. */ productId?: string | undefined; /** * The ID of the price associated with the subscription item. */ priceId?: string | undefined; /** * The number of units for the subscription item. */ units?: number | null | undefined; }; /** @internal */ export const SubscriptionItemEntity$inboundSchema: z.ZodType< SubscriptionItemEntity, z.ZodTypeDef, unknown > = z.object({ id: z.string(), mode: EnvironmentMode$inboundSchema, object: z.string(), product_id: z.string().optional(), price_id: z.string().optional(), units: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { "product_id": "productId", "price_id": "priceId", }); }); /** @internal */ export type SubscriptionItemEntity$Outbound = { id: string; mode: string; object: string; product_id?: string | undefined; price_id?: string | undefined; units?: number | null | undefined; }; /** @internal */ export const SubscriptionItemEntity$outboundSchema: z.ZodType< SubscriptionItemEntity$Outbound, z.ZodTypeDef, SubscriptionItemEntity > = z.object({ id: z.string(), mode: EnvironmentMode$outboundSchema, object: z.string(), productId: z.string().optional(), priceId: z.string().optional(), units: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { productId: "product_id", priceId: "price_id", }); }); export function subscriptionItemEntityToJSON( subscriptionItemEntity: SubscriptionItemEntity, ): string { return JSON.stringify( SubscriptionItemEntity$outboundSchema.parse(subscriptionItemEntity), ); } export function subscriptionItemEntityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubscriptionItemEntity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubscriptionItemEntity' from JSON`, ); }