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

from ..core.unchecked_base_model import UncheckedBaseModel
import pydantic
import typing
from .loyalty_promotion_trigger_limit_interval import LoyaltyPromotionTriggerLimitInterval
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class LoyaltyPromotionTriggerLimit(UncheckedBaseModel):
    """
    Represents the number of times a buyer can earn points during a [loyalty promotion](entity:LoyaltyPromotion).
    If this field is not set, buyers can trigger the promotion an unlimited number of times to earn points during
    the time that the promotion is available.

    A purchase that is disqualified from earning points because of this limit might qualify for another active promotion.
    """

    times: int = pydantic.Field()
    """
    The maximum number of times a buyer can trigger the promotion during the specified `interval`.
    """

    interval: typing.Optional[LoyaltyPromotionTriggerLimitInterval] = pydantic.Field(default=None)
    """
    The time period the limit applies to.
    See [LoyaltyPromotionTriggerLimitInterval](#type-loyaltypromotiontriggerlimitinterval) for possible values
    """

    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
