/* * 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 { ChangedResources, ChangedResources$inboundSchema, } from "./changed-resources.js"; import { EntityChangeResult, EntityChangeResult$inboundSchema, } from "./entity-change-result.js"; import { PlanSummary, PlanSummary$inboundSchema } from "./plan-summary.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { SubscriptionChangeBillingPeriodResult, SubscriptionChangeBillingPeriodResult$inboundSchema, } from "./subscription-change-billing-period-result.js"; import { SubscriptionChangeType, SubscriptionChangeType$inboundSchema, } from "./subscription-change-type.js"; import { SubscriptionResponse, SubscriptionResponse$inboundSchema, } from "./subscription-response.js"; export type SubscriptionChangeV2Response = { billingPeriod?: SubscriptionChangeBillingPeriodResult | undefined; changeType?: SubscriptionChangeType | undefined; changedResources?: ChangedResources | undefined; effectiveAt?: Date | undefined; entityChanges?: Array | undefined; fromPlan?: PlanSummary | undefined; /** * IsScheduled is true when the change was deferred to the period end instead * * @remarks * of being applied immediately. */ isScheduled?: boolean | undefined; metadata?: { [k: string]: string } | undefined; scheduleId?: string | undefined; scheduledAt?: Date | undefined; subscription?: SubscriptionResponse | undefined; /** * SupersededSchedules lists the plan-change schedules this request cancelled under * * @remarks * on_conflict_policies.on_pending_schedule. Preview reports what execute would cancel. */ supersededSchedules?: Array | undefined; toPlan?: PlanSummary | undefined; warnings?: Array | undefined; }; /** @internal */ export const SubscriptionChangeV2Response$inboundSchema: z.ZodMiniType< SubscriptionChangeV2Response, unknown > = z.pipe( z.object({ billing_period: types.optional( SubscriptionChangeBillingPeriodResult$inboundSchema, ), change_type: types.optional(SubscriptionChangeType$inboundSchema), changed_resources: types.optional(ChangedResources$inboundSchema), effective_at: types.optional(types.date()), entity_changes: types.optional(z.array(EntityChangeResult$inboundSchema)), from_plan: types.optional(PlanSummary$inboundSchema), is_scheduled: types.optional(types.boolean()), metadata: types.optional(z.record(z.string(), types.string())), schedule_id: types.optional(types.string()), scheduled_at: types.optional(types.date()), subscription: types.optional(SubscriptionResponse$inboundSchema), superseded_schedules: types.optional(z.array(types.string())), to_plan: types.optional(PlanSummary$inboundSchema), warnings: types.optional(z.array(types.string())), }), z.transform((v) => { return remap$(v, { "billing_period": "billingPeriod", "change_type": "changeType", "changed_resources": "changedResources", "effective_at": "effectiveAt", "entity_changes": "entityChanges", "from_plan": "fromPlan", "is_scheduled": "isScheduled", "schedule_id": "scheduleId", "scheduled_at": "scheduledAt", "superseded_schedules": "supersededSchedules", "to_plan": "toPlan", }); }), ); export function subscriptionChangeV2ResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubscriptionChangeV2Response$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubscriptionChangeV2Response' from JSON`, ); }