# This file was auto-generated by Fern from our API Definition.

from ..core.unchecked_base_model import UncheckedBaseModel
import pydantic
from .loyalty_event_type import LoyaltyEventType
import typing
from .loyalty_event_accumulate_points import LoyaltyEventAccumulatePoints
from .loyalty_event_create_reward import LoyaltyEventCreateReward
from .loyalty_event_redeem_reward import LoyaltyEventRedeemReward
from .loyalty_event_delete_reward import LoyaltyEventDeleteReward
from .loyalty_event_adjust_points import LoyaltyEventAdjustPoints
from .loyalty_event_source import LoyaltyEventSource
from .loyalty_event_expire_points import LoyaltyEventExpirePoints
from .loyalty_event_other import LoyaltyEventOther
from .loyalty_event_accumulate_promotion_points import LoyaltyEventAccumulatePromotionPoints
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class LoyaltyEvent(UncheckedBaseModel):
    """
    Provides information about a loyalty event.
    For more information, see [Search for Balance-Changing Loyalty Events](https://developer.squareup.com/docs/loyalty-api/loyalty-events).
    """

    id: str = pydantic.Field()
    """
    The Square-assigned ID of the loyalty event.
    """

    type: LoyaltyEventType = pydantic.Field()
    """
    The type of the loyalty event.
    See [LoyaltyEventType](#type-loyaltyeventtype) for possible values
    """

    created_at: str = pydantic.Field()
    """
    The timestamp when the event was created, in RFC 3339 format.
    """

    accumulate_points: typing.Optional[LoyaltyEventAccumulatePoints] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `ACCUMULATE_POINTS`.
    """

    create_reward: typing.Optional[LoyaltyEventCreateReward] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `CREATE_REWARD`.
    """

    redeem_reward: typing.Optional[LoyaltyEventRedeemReward] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `REDEEM_REWARD`.
    """

    delete_reward: typing.Optional[LoyaltyEventDeleteReward] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `DELETE_REWARD`.
    """

    adjust_points: typing.Optional[LoyaltyEventAdjustPoints] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `ADJUST_POINTS`.
    """

    loyalty_account_id: str = pydantic.Field()
    """
    The ID of the [loyalty account](entity:LoyaltyAccount) associated with the event.
    """

    location_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The ID of the [location](entity:Location) where the event occurred.
    """

    source: LoyaltyEventSource = pydantic.Field()
    """
    Defines whether the event was generated by the Square Point of Sale.
    See [LoyaltyEventSource](#type-loyaltyeventsource) for possible values
    """

    expire_points: typing.Optional[LoyaltyEventExpirePoints] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `EXPIRE_POINTS`.
    """

    other_event: typing.Optional[LoyaltyEventOther] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `OTHER`.
    """

    accumulate_promotion_points: typing.Optional[LoyaltyEventAccumulatePromotionPoints] = pydantic.Field(default=None)
    """
    Provides metadata when the event `type` is `ACCUMULATE_PROMOTION_POINTS`.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
