/* * 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 { CancellationType, CancellationType$inboundSchema, } from "./cancellation-type.js"; import { InvoiceResponse, InvoiceResponse$inboundSchema, } from "./invoice-response.js"; import { ProrationDetail, ProrationDetail$inboundSchema, } from "./proration-detail.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { SubscriptionStatus, SubscriptionStatus$inboundSchema, } from "./subscription-status.js"; export type CancelSubscriptionResponse = { cancellationType?: CancellationType | undefined; effectiveDate?: Date | undefined; /** * Response metadata */ message?: string | undefined; processedAt?: Date | undefined; prorationDetails?: Array | undefined; prorationInvoice?: InvoiceResponse | undefined; reason?: string | undefined; status?: SubscriptionStatus | undefined; /** * Basic cancellation info */ subscriptionId?: string | undefined; totalCreditAmount?: string | undefined; }; /** @internal */ export const CancelSubscriptionResponse$inboundSchema: z.ZodMiniType< CancelSubscriptionResponse, unknown > = z.pipe( z.object({ cancellation_type: types.optional(CancellationType$inboundSchema), effective_date: types.optional(types.date()), message: types.optional(types.string()), processed_at: types.optional(types.date()), proration_details: types.optional(z.array(ProrationDetail$inboundSchema)), proration_invoice: types.optional(InvoiceResponse$inboundSchema), reason: types.optional(types.string()), status: types.optional(SubscriptionStatus$inboundSchema), subscription_id: types.optional(types.string()), total_credit_amount: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "cancellation_type": "cancellationType", "effective_date": "effectiveDate", "processed_at": "processedAt", "proration_details": "prorationDetails", "proration_invoice": "prorationInvoice", "subscription_id": "subscriptionId", "total_credit_amount": "totalCreditAmount", }); }), ); export function cancelSubscriptionResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CancelSubscriptionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CancelSubscriptionResponse' from JSON`, ); }