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

from __future__ import annotations
from .benefitads import BenefitAds, BenefitAdsTypedDict
from .benefitarticles import BenefitArticles, BenefitArticlesTypedDict
from .benefitcustom import BenefitCustom, BenefitCustomTypedDict
from .benefitdiscord import BenefitDiscordInput, BenefitDiscordInputTypedDict
from .benefitdownloadables import BenefitDownloadables, BenefitDownloadablesTypedDict
from .benefitgithubrepository import (
    BenefitGitHubRepository,
    BenefitGitHubRepositoryTypedDict,
)
from .benefitlicensekeys import BenefitLicenseKeys, BenefitLicenseKeysTypedDict
from enum import Enum
from polar_sdk.types import BaseModel
from polar_sdk.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import Union
from typing_extensions import Annotated, TypedDict


class WebhookBenefitUpdatedPayloadType(str, Enum):
    BENEFIT_UPDATED = "benefit.updated"


WebhookBenefitUpdatedPayloadBenefitTypedDict = Union[
    BenefitArticlesTypedDict,
    BenefitAdsTypedDict,
    BenefitDiscordInputTypedDict,
    BenefitGitHubRepositoryTypedDict,
    BenefitDownloadablesTypedDict,
    BenefitLicenseKeysTypedDict,
    BenefitCustomTypedDict,
]


WebhookBenefitUpdatedPayloadBenefit = Union[
    BenefitArticles,
    BenefitAds,
    BenefitDiscordInput,
    BenefitGitHubRepository,
    BenefitDownloadables,
    BenefitLicenseKeys,
    BenefitCustom,
]


class WebhookBenefitUpdatedPayloadTypedDict(TypedDict):
    r"""Sent when a benefit is updated.

    **Discord & Slack support:** Basic
    """

    data: WebhookBenefitUpdatedPayloadBenefitTypedDict
    type: WebhookBenefitUpdatedPayloadType


class WebhookBenefitUpdatedPayload(BaseModel):
    r"""Sent when a benefit is updated.

    **Discord & Slack support:** Basic
    """

    data: WebhookBenefitUpdatedPayloadBenefit

    TYPE: Annotated[
        Annotated[
            WebhookBenefitUpdatedPayloadType,
            AfterValidator(
                validate_const(WebhookBenefitUpdatedPayloadType.BENEFIT_UPDATED)
            ),
        ],
        pydantic.Field(alias="type"),
    ] = WebhookBenefitUpdatedPayloadType.BENEFIT_UPDATED
