"""cellpointapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
import dateutil.parser

from cellpointapi.api_helper import APIHelper


class LoyaltyAccount(object):
    """Implementation of the 'LoyaltyAccount' model.

    Loyalty account information.

    Attributes:
        program (str): Name of the loyalty program.
        number (str): Unique loyalty number associated with an individual customer.
        tier (str): Tier that customer has achieved in the program.
        joined (date): Date that the program was joined by the customer.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "program": "program",
        "number": "number",
        "tier": "tier",
        "joined": "joined",
    }

    _optionals = [
        "tier",
        "joined",
    ]

    def __init__(
        self,
        program=None,
        number=None,
        tier=APIHelper.SKIP,
        joined=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a LoyaltyAccount instance."""
        # Initialize members of the class
        self.program = program
        self.number = number
        if tier is not APIHelper.SKIP:
            self.tier = tier
        if joined is not APIHelper.SKIP:
            self.joined = joined

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        program =\
            dictionary.get("program")\
            if dictionary.get("program")\
                else None
        number =\
            dictionary.get("number")\
            if dictionary.get("number")\
                else None
        tier =\
            dictionary.get("tier")\
            if dictionary.get("tier")\
                else APIHelper.SKIP
        joined = dateutil.parser.parse(
            dictionary.get("joined")).date()\
            if dictionary.get("joined") else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(program,
                   number,
                   tier,
                   joined,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _program=self.program
        _number=self.number
        _tier=(
            self.tier
            if hasattr(self, "tier")
            else None
        )
        _joined=(
            self.joined
            if hasattr(self, "joined")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"program={_program!r}, "
            f"number={_number!r}, "
            f"tier={_tier!r}, "
            f"joined={_joined!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _program=self.program
        _number=self.number
        _tier=(
            self.tier
            if hasattr(self, "tier")
            else None
        )
        _joined=(
            self.joined
            if hasattr(self, "joined")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"program={_program!s}, "
            f"number={_number!s}, "
            f"tier={_tier!s}, "
            f"joined={_joined!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
