"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .subscription import Subscription, SubscriptionTypedDict
from datetime import datetime
from polar_sdk.types import BaseModel
from polar_sdk.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import Literal
from typing_extensions import Annotated, TypedDict


class WebhookSubscriptionPastDuePayloadTypedDict(TypedDict):
    r"""Sent when a subscription payment fails and the subscription enters `past_due` status.

    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
    """

    timestamp: datetime
    data: SubscriptionTypedDict
    type: Literal["subscription.past_due"]


class WebhookSubscriptionPastDuePayload(BaseModel):
    r"""Sent when a subscription payment fails and the subscription enters `past_due` status.

    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
    """

    timestamp: datetime

    data: Subscription

    TYPE: Annotated[
        Annotated[
            Literal["subscription.past_due"],
            AfterValidator(validate_const("subscription.past_due")),
        ],
        pydantic.Field(alias="type"),
    ] = "subscription.past_due"
