"""mindbodypublicapi.

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

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


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

    Attributes:
        sale_id (int): The sale ID associated with the particular item. It Filters
            results to the requested sale ID.
        start_sale_date_time (datetime): Filters results to sales that happened after
            this date and time.
        end_sale_date_time (datetime): Filters results to sales that happened before
            this date and time.
        payment_method_id (int): Filters results to sales paid for by the given
            payment method ID which indicates payment method(s) (i.e. cash, VISA,
            AMEX, Check, etc.).
        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 = {
        "sale_id": "SaleId",
        "start_sale_date_time": "StartSaleDateTime",
        "end_sale_date_time": "EndSaleDateTime",
        "payment_method_id": "PaymentMethodId",
        "limit": "Limit",
        "offset": "Offset",
    }

    _optionals = [
        "sale_id",
        "start_sale_date_time",
        "end_sale_date_time",
        "payment_method_id",
        "limit",
        "offset",
    ]

    def __init__(
        self,
        sale_id=APIHelper.SKIP,
        start_sale_date_time=APIHelper.SKIP,
        end_sale_date_time=APIHelper.SKIP,
        payment_method_id=APIHelper.SKIP,
        limit=APIHelper.SKIP,
        offset=APIHelper.SKIP):
        """Initialize a GetSalesRequest instance."""
        # Initialize members of the class
        if sale_id is not APIHelper.SKIP:
            self.sale_id = sale_id
        if start_sale_date_time is not APIHelper.SKIP:
            self.start_sale_date_time =\
                 APIHelper.apply_datetime_converter(
                start_sale_date_time, APIHelper.RFC3339DateTime)\
                 if start_sale_date_time else None
        if end_sale_date_time is not APIHelper.SKIP:
            self.end_sale_date_time =\
                 APIHelper.apply_datetime_converter(
                end_sale_date_time, APIHelper.RFC3339DateTime)\
                 if end_sale_date_time else None
        if payment_method_id is not APIHelper.SKIP:
            self.payment_method_id = payment_method_id
        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
        sale_id =\
            dictionary.get("SaleId")\
            if dictionary.get("SaleId")\
                else APIHelper.SKIP
        start_sale_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("StartSaleDateTime")).datetime\
            if dictionary.get("StartSaleDateTime") else APIHelper.SKIP
        end_sale_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("EndSaleDateTime")).datetime\
            if dictionary.get("EndSaleDateTime") else APIHelper.SKIP
        payment_method_id =\
            dictionary.get("PaymentMethodId")\
            if dictionary.get("PaymentMethodId")\
                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(sale_id,
                   start_sale_date_time,
                   end_sale_date_time,
                   payment_method_id,
                   limit,
                   offset)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _start_sale_date_time=(
            self.start_sale_date_time
            if hasattr(self, "start_sale_date_time")
            else None
        )
        _end_sale_date_time=(
            self.end_sale_date_time
            if hasattr(self, "end_sale_date_time")
            else None
        )
        _payment_method_id=(
            self.payment_method_id
            if hasattr(self, "payment_method_id")
            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"sale_id={_sale_id!r}, "
            f"start_sale_date_time={_start_sale_date_time!r}, "
            f"end_sale_date_time={_end_sale_date_time!r}, "
            f"payment_method_id={_payment_method_id!r}, "
            f"limit={_limit!r}, "
            f"offset={_offset!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _start_sale_date_time=(
            self.start_sale_date_time
            if hasattr(self, "start_sale_date_time")
            else None
        )
        _end_sale_date_time=(
            self.end_sale_date_time
            if hasattr(self, "end_sale_date_time")
            else None
        )
        _payment_method_id=(
            self.payment_method_id
            if hasattr(self, "payment_method_id")
            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"sale_id={_sale_id!s}, "
            f"start_sale_date_time={_start_sale_date_time!s}, "
            f"end_sale_date_time={_end_sale_date_time!s}, "
            f"payment_method_id={_payment_method_id!s}, "
            f"limit={_limit!s}, "
            f"offset={_offset!s}, "
            f")"
        )
