"""paypalserversdk.

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

# ruff: noqa: E501
class Frequency(object):
    """Implementation of the 'Frequency' model.

    The frequency of the billing cycle.

    Attributes:
        interval_unit (IntervalUnit): The interval at which the subscription is
            charged or billed.
        interval_count (int): The number of intervals after which a subscriber is
            billed. For example, if the `interval_unit` is `DAY` with an
            `interval_count` of  `2`, the subscription is billed once every two days.
            The following table lists the maximum allowed values for the
            `interval_count` for each `interval_unit`: Interval unit Maximum interval
            count DAY 365 WEEK 52 MONTH 12 YEAR 1

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "interval_unit": "interval_unit",
        "interval_count": "interval_count",
    }

    _optionals = [
        "interval_count",
    ]

    def __init__(
        self,
        interval_unit=None,
        interval_count=1):
        """Initialize a Frequency instance."""
        # Initialize members of the class
        self.interval_unit = interval_unit
        self.interval_count = interval_count

    @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
        interval_unit =\
            dictionary.get("interval_unit")\
            if dictionary.get("interval_unit")\
                else None
        interval_count =\
            dictionary.get("interval_count")\
            if dictionary.get("interval_count")\
                else 1

        # Return an object of this model
        return cls(interval_unit,
                   interval_count)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _interval_unit=self.interval_unit
        _interval_count=(
            self.interval_count
            if hasattr(self, "interval_count")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"interval_unit={_interval_unit!r}, "
            f"interval_count={_interval_count!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _interval_unit=self.interval_unit
        _interval_count=(
            self.interval_count
            if hasattr(self, "interval_count")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"interval_unit={_interval_unit!s}, "
            f"interval_count={_interval_count!s}, "
            f")"
        )
