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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
import pydantic
from .loyalty_program_status import LoyaltyProgramStatus
from .loyalty_program_reward_tier import LoyaltyProgramRewardTier
from .loyalty_program_expiration_policy import LoyaltyProgramExpirationPolicy
from .loyalty_program_terminology import LoyaltyProgramTerminology
from .loyalty_program_accrual_rule import LoyaltyProgramAccrualRule
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class LoyaltyProgram(UncheckedBaseModel):
    """
    Represents a Square loyalty program. Loyalty programs define how buyers can earn points and redeem points for rewards.
    Square sellers can have only one loyalty program, which is created and managed from the Seller Dashboard.
    For more information, see [Loyalty Program Overview](https://developer.squareup.com/docs/loyalty/overview).
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The Square-assigned ID of the loyalty program. Updates to 
    the loyalty program do not modify the identifier.
    """

    status: typing.Optional[LoyaltyProgramStatus] = pydantic.Field(default=None)
    """
    Whether the program is currently active.
    See [LoyaltyProgramStatus](#type-loyaltyprogramstatus) for possible values
    """

    reward_tiers: typing.Optional[typing.List[LoyaltyProgramRewardTier]] = pydantic.Field(default=None)
    """
    The list of rewards for buyers, sorted by ascending points.
    """

    expiration_policy: typing.Optional[LoyaltyProgramExpirationPolicy] = pydantic.Field(default=None)
    """
    If present, details for how points expire.
    """

    terminology: typing.Optional[LoyaltyProgramTerminology] = pydantic.Field(default=None)
    """
    A cosmetic name for the “points” currency.
    """

    location_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    The [locations](entity:Location) at which the program is active.
    """

    created_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    The timestamp when the program was created, in RFC 3339 format.
    """

    updated_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    The timestamp when the reward was last updated, in RFC 3339 format.
    """

    accrual_rules: typing.Optional[typing.List[LoyaltyProgramAccrualRule]] = pydantic.Field(default=None)
    """
    Defines how buyers can earn loyalty points from the base loyalty program.
    To check for associated [loyalty promotions](entity:LoyaltyPromotion) that enable
    buyers to earn extra points, call [ListLoyaltyPromotions](api-endpoint:Loyalty-ListLoyaltyPromotions).
    """

    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
