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

from ..core.unchecked_base_model import UncheckedBaseModel
from .loyalty_program_accrual_rule_type import LoyaltyProgramAccrualRuleType
import pydantic
import typing
from .loyalty_program_accrual_rule_visit_data import LoyaltyProgramAccrualRuleVisitData
from .loyalty_program_accrual_rule_spend_data import LoyaltyProgramAccrualRuleSpendData
from .loyalty_program_accrual_rule_item_variation_data import LoyaltyProgramAccrualRuleItemVariationData
from .loyalty_program_accrual_rule_category_data import LoyaltyProgramAccrualRuleCategoryData
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class LoyaltyProgramAccrualRule(UncheckedBaseModel):
    """
    Represents an accrual rule, which defines how buyers can earn points from the base [loyalty program](entity:LoyaltyProgram).
    """

    accrual_type: LoyaltyProgramAccrualRuleType = pydantic.Field()
    """
    The type of the accrual rule that defines how buyers can earn points.
    See [LoyaltyProgramAccrualRuleType](#type-loyaltyprogramaccrualruletype) for possible values
    """

    points: typing.Optional[int] = pydantic.Field(default=None)
    """
    The number of points that 
    buyers earn based on the `accrual_type`.
    """

    visit_data: typing.Optional[LoyaltyProgramAccrualRuleVisitData] = pydantic.Field(default=None)
    """
    Additional data for rules with the `VISIT` accrual type.
    """

    spend_data: typing.Optional[LoyaltyProgramAccrualRuleSpendData] = pydantic.Field(default=None)
    """
    Additional data for rules with the `SPEND` accrual type.
    """

    item_variation_data: typing.Optional[LoyaltyProgramAccrualRuleItemVariationData] = pydantic.Field(default=None)
    """
    Additional data for rules with the `ITEM_VARIATION` accrual type.
    """

    category_data: typing.Optional[LoyaltyProgramAccrualRuleCategoryData] = pydantic.Field(default=None)
    """
    Additional data for rules with the `CATEGORY` accrual type.
    """

    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
