/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Subscription, Subscription$inboundSchema, Subscription$Outbound, Subscription$outboundSchema, } from "./subscription.js"; /** * Sent when a subscription payment fails and the subscription enters `past_due` status. * * @remarks * * This is a recoverable state - the customer can update their payment method to restore the subscription. * Benefits may be revoked depending on the organization's grace period settings. * * If payment retries are exhausted, a `subscription.revoked` event will be sent. * * **Discord & Slack support:** Full */ export type WebhookSubscriptionPastDuePayload = { type: "subscription.past_due"; timestamp: Date; data: Subscription; }; /** @internal */ export const WebhookSubscriptionPastDuePayload$inboundSchema: z.ZodMiniType< WebhookSubscriptionPastDuePayload, unknown > = z.object({ type: z.literal("subscription.past_due"), timestamp: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), data: Subscription$inboundSchema, }); /** @internal */ export type WebhookSubscriptionPastDuePayload$Outbound = { type: "subscription.past_due"; timestamp: string; data: Subscription$Outbound; }; /** @internal */ export const WebhookSubscriptionPastDuePayload$outboundSchema: z.ZodMiniType< WebhookSubscriptionPastDuePayload$Outbound, WebhookSubscriptionPastDuePayload > = z.object({ type: z.literal("subscription.past_due"), timestamp: z.pipe(z.date(), z.transform(v => v.toISOString())), data: Subscription$outboundSchema, }); export function webhookSubscriptionPastDuePayloadToJSON( webhookSubscriptionPastDuePayload: WebhookSubscriptionPastDuePayload, ): string { return JSON.stringify( WebhookSubscriptionPastDuePayload$outboundSchema.parse( webhookSubscriptionPastDuePayload, ), ); } export function webhookSubscriptionPastDuePayloadFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookSubscriptionPastDuePayload$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookSubscriptionPastDuePayload' from JSON`, ); }