"""mindbodypublicapi.

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

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper


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

    Attributes:
        frequency_type (str): Defines how often clients are charged. Possible values
            are:  * SetNumberOfAutopays  * MonthToMonth
        frequency_value (int): The interval of AutoPay frequency, combined with
            `FrequencyTimeUnit`. This value is null if `FrequencyType` is
            `MonthToMonth`.
        frequency_time_unit (str): Defines the time unit that sets how often to run
            the AutoPay, combined with `FrequencyValue`. This value is null if
            `FrequencyType` is `MonthToMonth`. Possible values are:  * Weekly  *
            Monthly  * Yearly

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "frequency_type": "FrequencyType",
        "frequency_value": "FrequencyValue",
        "frequency_time_unit": "FrequencyTimeUnit",
    }

    _optionals = [
        "frequency_type",
        "frequency_value",
        "frequency_time_unit",
    ]

    def __init__(
        self,
        frequency_type=APIHelper.SKIP,
        frequency_value=APIHelper.SKIP,
        frequency_time_unit=APIHelper.SKIP):
        """Initialize a AutopaySchedule instance."""
        # Initialize members of the class
        if frequency_type is not APIHelper.SKIP:
            self.frequency_type = frequency_type
        if frequency_value is not APIHelper.SKIP:
            self.frequency_value = frequency_value
        if frequency_time_unit is not APIHelper.SKIP:
            self.frequency_time_unit = frequency_time_unit

    @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
        frequency_type =\
            dictionary.get("FrequencyType")\
            if dictionary.get("FrequencyType")\
                else APIHelper.SKIP
        frequency_value =\
            dictionary.get("FrequencyValue")\
            if dictionary.get("FrequencyValue")\
                else APIHelper.SKIP
        frequency_time_unit =\
            dictionary.get("FrequencyTimeUnit")\
            if dictionary.get("FrequencyTimeUnit")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(frequency_type,
                   frequency_value,
                   frequency_time_unit)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _frequency_type=(
            self.frequency_type
            if hasattr(self, "frequency_type")
            else None
        )
        _frequency_value=(
            self.frequency_value
            if hasattr(self, "frequency_value")
            else None
        )
        _frequency_time_unit=(
            self.frequency_time_unit
            if hasattr(self, "frequency_time_unit")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"frequency_type={_frequency_type!r}, "
            f"frequency_value={_frequency_value!r}, "
            f"frequency_time_unit={_frequency_time_unit!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _frequency_type=(
            self.frequency_type
            if hasattr(self, "frequency_type")
            else None
        )
        _frequency_value=(
            self.frequency_value
            if hasattr(self, "frequency_value")
            else None
        )
        _frequency_time_unit=(
            self.frequency_time_unit
            if hasattr(self, "frequency_time_unit")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"frequency_type={_frequency_type!s}, "
            f"frequency_value={_frequency_value!s}, "
            f"frequency_time_unit={_frequency_time_unit!s}, "
            f")"
        )
