/* * 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 { BillingCycleInfo, BillingCycleInfo$inboundSchema, } from "./billing-cycle-info.js"; import { InvoicePreview, InvoicePreview$inboundSchema, } from "./invoice-preview.js"; import { PlanSummary, PlanSummary$inboundSchema } from "./plan-summary.js"; import { ProrationDetails, ProrationDetails$inboundSchema, } from "./proration-details.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { SubscriptionChangeType, SubscriptionChangeType$inboundSchema, } from "./subscription-change-type.js"; /** * Response showing the financial impact of a subscription plan change */ export type SubscriptionChangePreviewResponse = { changeType?: SubscriptionChangeType | undefined; currentPlan?: PlanSummary | undefined; /** * effective_date is when the change would take effect */ effectiveDate?: Date | undefined; /** * metadata from the request */ metadata?: { [k: string]: string } | undefined; newBillingCycle?: BillingCycleInfo | undefined; nextInvoicePreview?: InvoicePreview | undefined; prorationDetails?: ProrationDetails | undefined; /** * subscription_id is the ID of the subscription being changed */ subscriptionId?: string | undefined; targetPlan?: PlanSummary | undefined; /** * warnings contains any warnings about the change */ warnings?: Array | undefined; }; /** @internal */ export const SubscriptionChangePreviewResponse$inboundSchema: z.ZodMiniType< SubscriptionChangePreviewResponse, unknown > = z.pipe( z.object({ change_type: types.optional(SubscriptionChangeType$inboundSchema), current_plan: types.optional(PlanSummary$inboundSchema), effective_date: types.optional(types.date()), metadata: types.optional(z.record(z.string(), types.string())), new_billing_cycle: types.optional(BillingCycleInfo$inboundSchema), next_invoice_preview: types.optional(InvoicePreview$inboundSchema), proration_details: types.optional(ProrationDetails$inboundSchema), subscription_id: types.optional(types.string()), target_plan: types.optional(PlanSummary$inboundSchema), warnings: types.optional(z.array(types.string())), }), z.transform((v) => { return remap$(v, { "change_type": "changeType", "current_plan": "currentPlan", "effective_date": "effectiveDate", "new_billing_cycle": "newBillingCycle", "next_invoice_preview": "nextInvoicePreview", "proration_details": "prorationDetails", "subscription_id": "subscriptionId", "target_plan": "targetPlan", }); }), ); export function subscriptionChangePreviewResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubscriptionChangePreviewResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubscriptionChangePreviewResponse' from JSON`, ); }