/* * 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 { BillingCadence, BillingCadence$outboundSchema, } from "./billing-cadence.js"; import { BillingCycle, BillingCycle$outboundSchema } from "./billing-cycle.js"; import { BillingPeriod, BillingPeriod$outboundSchema, } from "./billing-period.js"; import { ProrationBehavior, ProrationBehavior$outboundSchema, } from "./proration-behavior.js"; import { ScheduleType, ScheduleType$outboundSchema } from "./schedule-type.js"; /** * Request object for changing a subscription plan (upgrade/downgrade) */ export type SubscriptionChangeRequest = { billingCadence: BillingCadence; billingCycle: BillingCycle; billingPeriod: BillingPeriod; /** * billing_period_count is the billing period count for the new subscription */ billingPeriodCount?: number | undefined; changeAt?: ScheduleType | undefined; /** * metadata contains additional key-value pairs for storing extra information */ metadata?: { [k: string]: string } | undefined; prorationBehavior: ProrationBehavior; /** * target_plan_id is the ID of the new plan to change to (required) */ targetPlanId: string; }; /** @internal */ export type SubscriptionChangeRequest$Outbound = { billing_cadence: string; billing_cycle: string; billing_period: string; billing_period_count?: number | undefined; change_at?: string | undefined; metadata?: { [k: string]: string } | undefined; proration_behavior: string; target_plan_id: string; }; /** @internal */ export const SubscriptionChangeRequest$outboundSchema: z.ZodMiniType< SubscriptionChangeRequest$Outbound, SubscriptionChangeRequest > = z.pipe( z.object({ billingCadence: BillingCadence$outboundSchema, billingCycle: BillingCycle$outboundSchema, billingPeriod: BillingPeriod$outboundSchema, billingPeriodCount: z.optional(z.int()), changeAt: z.optional(ScheduleType$outboundSchema), metadata: z.optional(z.record(z.string(), z.string())), prorationBehavior: ProrationBehavior$outboundSchema, targetPlanId: z.string(), }), z.transform((v) => { return remap$(v, { billingCadence: "billing_cadence", billingCycle: "billing_cycle", billingPeriod: "billing_period", billingPeriodCount: "billing_period_count", changeAt: "change_at", prorationBehavior: "proration_behavior", targetPlanId: "target_plan_id", }); }), ); export function subscriptionChangeRequestToJSON( subscriptionChangeRequest: SubscriptionChangeRequest, ): string { return JSON.stringify( SubscriptionChangeRequest$outboundSchema.parse(subscriptionChangeRequest), ); }