/* * 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 { BillingCadence, BillingCadence$inboundSchema, } from "./billing-cadence.js"; import { BillingPeriod, BillingPeriod$inboundSchema, } from "./billing-period.js"; import { PauseStatus, PauseStatus$inboundSchema } from "./pause-status.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { SubscriptionStatus, SubscriptionStatus$inboundSchema, } from "./subscription-status.js"; import { SubscriptionType, SubscriptionType$inboundSchema, } from "./subscription-type.js"; import { WebhookDtoCustomer, WebhookDtoCustomer$inboundSchema, } from "./webhook-dto-customer.js"; export type WebhookDtoSubscription = { billingCadence?: BillingCadence | undefined; billingPeriod?: BillingPeriod | undefined; billingPeriodCount?: number | undefined; cancelAt?: Date | undefined; cancelAtPeriodEnd?: boolean | undefined; cancelledAt?: Date | undefined; currency?: string | undefined; currentPeriodEnd?: Date | undefined; currentPeriodStart?: Date | undefined; customer?: WebhookDtoCustomer | undefined; customerId?: string | undefined; endDate?: Date | undefined; id?: string | undefined; lookupKey?: string | undefined; metadata?: { [k: string]: string } | undefined; parentSubscriptionId?: string | undefined; pauseStatus?: PauseStatus | undefined; planId?: string | undefined; startDate?: Date | undefined; subscriptionStatus?: SubscriptionStatus | undefined; subscriptionType?: SubscriptionType | undefined; trialEnd?: Date | undefined; trialStart?: Date | undefined; }; /** @internal */ export const WebhookDtoSubscription$inboundSchema: z.ZodMiniType< WebhookDtoSubscription, unknown > = z.pipe( z.object({ billing_cadence: types.optional(BillingCadence$inboundSchema), billing_period: types.optional(BillingPeriod$inboundSchema), billing_period_count: types.optional(types.number()), cancel_at: types.optional(types.date()), cancel_at_period_end: types.optional(types.boolean()), cancelled_at: types.optional(types.date()), currency: types.optional(types.string()), current_period_end: types.optional(types.date()), current_period_start: types.optional(types.date()), customer: types.optional(WebhookDtoCustomer$inboundSchema), customer_id: types.optional(types.string()), end_date: types.optional(types.date()), id: types.optional(types.string()), lookup_key: types.optional(types.string()), metadata: types.optional(z.record(z.string(), types.string())), parent_subscription_id: types.optional(types.string()), pause_status: types.optional(PauseStatus$inboundSchema), plan_id: types.optional(types.string()), start_date: types.optional(types.date()), subscription_status: types.optional(SubscriptionStatus$inboundSchema), subscription_type: types.optional(SubscriptionType$inboundSchema), trial_end: types.optional(types.date()), trial_start: types.optional(types.date()), }), z.transform((v) => { return remap$(v, { "billing_cadence": "billingCadence", "billing_period": "billingPeriod", "billing_period_count": "billingPeriodCount", "cancel_at": "cancelAt", "cancel_at_period_end": "cancelAtPeriodEnd", "cancelled_at": "cancelledAt", "current_period_end": "currentPeriodEnd", "current_period_start": "currentPeriodStart", "customer_id": "customerId", "end_date": "endDate", "lookup_key": "lookupKey", "parent_subscription_id": "parentSubscriptionId", "pause_status": "pauseStatus", "plan_id": "planId", "start_date": "startDate", "subscription_status": "subscriptionStatus", "subscription_type": "subscriptionType", "trial_end": "trialEnd", "trial_start": "trialStart", }); }), ); export function webhookDtoSubscriptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookDtoSubscription$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookDtoSubscription' from JSON`, ); }