"""mindbodypublicapi.

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

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


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

    Attributes:
        active_only (bool): If true, filters results to show only promocodes that are
            active. If **false**, all promocodes are returned.  Default: **true**
        online_only (bool): If `true`, filters results to show only promocodes that
            can be used for online sale.  If `false`, all promocodes are returned.
            Default: **false**
        start_date (datetime): Filters results to promocodes that were activated
            after this date.
        end_date (datetime): Filters results to promocodes that were activated before
            this date.
        last_modified_date (datetime): Filters results to promocodes that were
            modified on or after this date.
        limit (int): Number of results to include, defaults to 100
        offset (int): Page offset, defaults to 0.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "active_only": "ActiveOnly",
        "online_only": "OnlineOnly",
        "start_date": "StartDate",
        "end_date": "EndDate",
        "last_modified_date": "LastModifiedDate",
        "limit": "Limit",
        "offset": "Offset",
    }

    _optionals = [
        "active_only",
        "online_only",
        "start_date",
        "end_date",
        "last_modified_date",
        "limit",
        "offset",
    ]

    def __init__(
        self,
        active_only=APIHelper.SKIP,
        online_only=APIHelper.SKIP,
        start_date=APIHelper.SKIP,
        end_date=APIHelper.SKIP,
        last_modified_date=APIHelper.SKIP,
        limit=APIHelper.SKIP,
        offset=APIHelper.SKIP):
        """Initialize a GetPromoCodesRequest instance."""
        # Initialize members of the class
        if active_only is not APIHelper.SKIP:
            self.active_only = active_only
        if online_only is not APIHelper.SKIP:
            self.online_only = online_only
        if start_date is not APIHelper.SKIP:
            self.start_date =\
                 APIHelper.apply_datetime_converter(
                start_date, APIHelper.RFC3339DateTime)\
                 if start_date else None
        if end_date is not APIHelper.SKIP:
            self.end_date =\
                 APIHelper.apply_datetime_converter(
                end_date, APIHelper.RFC3339DateTime)\
                 if end_date else None
        if last_modified_date is not APIHelper.SKIP:
            self.last_modified_date =\
                 APIHelper.apply_datetime_converter(
                last_modified_date, APIHelper.RFC3339DateTime)\
                 if last_modified_date else None
        if limit is not APIHelper.SKIP:
            self.limit = limit
        if offset is not APIHelper.SKIP:
            self.offset = offset

    @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
        active_only =\
            dictionary.get("ActiveOnly")\
            if "ActiveOnly" in dictionary.keys()\
                else APIHelper.SKIP
        online_only =\
            dictionary.get("OnlineOnly")\
            if "OnlineOnly" in dictionary.keys()\
                else APIHelper.SKIP
        start_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("StartDate")).datetime\
            if dictionary.get("StartDate") else APIHelper.SKIP
        end_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("EndDate")).datetime\
            if dictionary.get("EndDate") else APIHelper.SKIP
        last_modified_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("LastModifiedDate")).datetime\
            if dictionary.get("LastModifiedDate") else APIHelper.SKIP
        limit =\
            dictionary.get("Limit")\
            if dictionary.get("Limit")\
                else APIHelper.SKIP
        offset =\
            dictionary.get("Offset")\
            if dictionary.get("Offset")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(active_only,
                   online_only,
                   start_date,
                   end_date,
                   last_modified_date,
                   limit,
                   offset)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _active_only=(
            self.active_only
            if hasattr(self, "active_only")
            else None
        )
        _online_only=(
            self.online_only
            if hasattr(self, "online_only")
            else None
        )
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _end_date=(
            self.end_date
            if hasattr(self, "end_date")
            else None
        )
        _last_modified_date=(
            self.last_modified_date
            if hasattr(self, "last_modified_date")
            else None
        )
        _limit=(
            self.limit
            if hasattr(self, "limit")
            else None
        )
        _offset=(
            self.offset
            if hasattr(self, "offset")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"active_only={_active_only!r}, "
            f"online_only={_online_only!r}, "
            f"start_date={_start_date!r}, "
            f"end_date={_end_date!r}, "
            f"last_modified_date={_last_modified_date!r}, "
            f"limit={_limit!r}, "
            f"offset={_offset!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _active_only=(
            self.active_only
            if hasattr(self, "active_only")
            else None
        )
        _online_only=(
            self.online_only
            if hasattr(self, "online_only")
            else None
        )
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _end_date=(
            self.end_date
            if hasattr(self, "end_date")
            else None
        )
        _last_modified_date=(
            self.last_modified_date
            if hasattr(self, "last_modified_date")
            else None
        )
        _limit=(
            self.limit
            if hasattr(self, "limit")
            else None
        )
        _offset=(
            self.offset
            if hasattr(self, "offset")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"active_only={_active_only!s}, "
            f"online_only={_online_only!s}, "
            f"start_date={_start_date!s}, "
            f"end_date={_end_date!s}, "
            f"last_modified_date={_last_modified_date!s}, "
            f"limit={_limit!s}, "
            f"offset={_offset!s}, "
            f")"
        )
