/* * 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 { MetadataOutputType, MetadataOutputType$inboundSchema, } from "./metadataoutputtype.js"; import { ProductVisibility, ProductVisibility$inboundSchema, } from "./productvisibility.js"; import { SubscriptionRecurringInterval, SubscriptionRecurringInterval$inboundSchema, } from "./subscriptionrecurringinterval.js"; import { TrialInterval, TrialInterval$inboundSchema } from "./trialinterval.js"; /** * A product that a discount can be applied to. */ export type DiscountProduct = { metadata: { [k: string]: MetadataOutputType }; /** * The ID of the object. */ id: string; /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; /** * The interval unit for the trial period. */ trialInterval: TrialInterval | null; /** * The number of interval units for the trial period. */ trialIntervalCount: number | null; /** * The name of the product. */ name: string; /** * The description of the product. */ description: string | null; visibility: ProductVisibility; /** * The recurring interval of the product. If `None`, the product is a one-time purchase. */ recurringInterval: SubscriptionRecurringInterval | null; /** * Number of interval units of the subscription. If this is set to 1 the charge will happen every interval (e.g. every month), if set to 2 it will be every other month, and so on. None for one-time products. */ recurringIntervalCount: number | null; /** * Whether the product is a subscription. */ isRecurring: boolean; /** * Whether the product is archived and no longer available. */ isArchived: boolean; /** * The ID of the organization owning the product. */ organizationId: string; }; /** @internal */ export const DiscountProduct$inboundSchema: z.ZodMiniType< DiscountProduct, unknown > = z.pipe( z.object({ metadata: z.record(z.string(), MetadataOutputType$inboundSchema), 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))), ), trial_interval: z.nullable(TrialInterval$inboundSchema), trial_interval_count: z.nullable(z.int()), name: z.string(), description: z.nullable(z.string()), visibility: ProductVisibility$inboundSchema, recurring_interval: z.nullable(SubscriptionRecurringInterval$inboundSchema), recurring_interval_count: z.nullable(z.int()), is_recurring: z.boolean(), is_archived: z.boolean(), organization_id: z.string(), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "trial_interval": "trialInterval", "trial_interval_count": "trialIntervalCount", "recurring_interval": "recurringInterval", "recurring_interval_count": "recurringIntervalCount", "is_recurring": "isRecurring", "is_archived": "isArchived", "organization_id": "organizationId", }); }), ); export function discountProductFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DiscountProduct$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DiscountProduct' from JSON`, ); }