/* * 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 { CreditGrantResponse, CreditGrantResponse$inboundSchema, } from "./credit-grant-response.js"; import { InvoiceResponse, InvoiceResponse$inboundSchema, } from "./invoice-response.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"; import { SubscriptionSummary, SubscriptionSummary$inboundSchema, } from "./subscription-summary.js"; /** * Response after successfully executing a subscription plan change */ export type SubscriptionChangeExecuteResponse = { changeType?: SubscriptionChangeType | undefined; /** * credit_grants contains any credit grants created for proration credits */ creditGrants?: Array | undefined; /** * effective_date is when the change took effect */ effectiveDate?: Date | undefined; invoice?: InvoiceResponse | undefined; /** * is_scheduled indicates if the change was scheduled or executed immediately */ isScheduled?: boolean | undefined; /** * metadata from the request */ metadata?: { [k: string]: string } | undefined; newSubscription?: SubscriptionSummary | undefined; oldSubscription?: SubscriptionSummary | undefined; prorationApplied?: ProrationDetails | undefined; /** * schedule_id is the ID of the created schedule (only if is_scheduled=true) */ scheduleId?: string | undefined; /** * scheduled_at is when the change will execute (only if is_scheduled=true) */ scheduledAt?: Date | undefined; }; /** @internal */ export const SubscriptionChangeExecuteResponse$inboundSchema: z.ZodMiniType< SubscriptionChangeExecuteResponse, unknown > = z.pipe( z.object({ change_type: types.optional(SubscriptionChangeType$inboundSchema), credit_grants: types.optional(z.array(CreditGrantResponse$inboundSchema)), effective_date: types.optional(types.date()), invoice: types.optional(InvoiceResponse$inboundSchema), is_scheduled: types.optional(types.boolean()), metadata: types.optional(z.record(z.string(), types.string())), new_subscription: types.optional(SubscriptionSummary$inboundSchema), old_subscription: types.optional(SubscriptionSummary$inboundSchema), proration_applied: types.optional(ProrationDetails$inboundSchema), schedule_id: types.optional(types.string()), scheduled_at: types.optional(types.date()), }), z.transform((v) => { return remap$(v, { "change_type": "changeType", "credit_grants": "creditGrants", "effective_date": "effectiveDate", "is_scheduled": "isScheduled", "new_subscription": "newSubscription", "old_subscription": "oldSubscription", "proration_applied": "prorationApplied", "schedule_id": "scheduleId", "scheduled_at": "scheduledAt", }); }), ); export function subscriptionChangeExecuteResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubscriptionChangeExecuteResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubscriptionChangeExecuteResponse' from JSON`, ); }