"""mindbodypublicapi.

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

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


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

    Attributes:
        id (int): A unique identifier for this payment.
        amount (float): The total amount of sales that were made on the sale date,
            including all payment methods that were used and taxes that were
            collected.
        method (int): The method used to make this payment.
        mtype (str): The payment method type used for the client’s purchase.
        notes (str): Payment notes that are entered under the selected payment method
            in the Retail screen before completing the sale.
        transaction_id (int): The ID of transaction. Use this ID when calling the GET
            Transactions endpoint.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "amount": "Amount",
        "method": "Method",
        "mtype": "Type",
        "notes": "Notes",
        "transaction_id": "TransactionId",
    }

    _optionals = [
        "id",
        "amount",
        "method",
        "mtype",
        "notes",
        "transaction_id",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        amount=APIHelper.SKIP,
        method=APIHelper.SKIP,
        mtype=APIHelper.SKIP,
        notes=APIHelper.SKIP,
        transaction_id=APIHelper.SKIP):
        """Initialize a SalePayment instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if amount is not APIHelper.SKIP:
            self.amount = amount
        if method is not APIHelper.SKIP:
            self.method = method
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype
        if notes is not APIHelper.SKIP:
            self.notes = notes
        if transaction_id is not APIHelper.SKIP:
            self.transaction_id = transaction_id

    @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
        id =\
            dictionary.get("Id")\
            if dictionary.get("Id")\
                else APIHelper.SKIP
        amount =\
            dictionary.get("Amount")\
            if dictionary.get("Amount")\
                else APIHelper.SKIP
        method =\
            dictionary.get("Method")\
            if dictionary.get("Method")\
                else APIHelper.SKIP
        mtype =\
            dictionary.get("Type")\
            if dictionary.get("Type")\
                else APIHelper.SKIP
        notes =\
            dictionary.get("Notes")\
            if dictionary.get("Notes")\
                else APIHelper.SKIP
        transaction_id =\
            dictionary.get("TransactionId")\
            if dictionary.get("TransactionId")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   amount,
                   method,
                   mtype,
                   notes,
                   transaction_id)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _method=(
            self.method
            if hasattr(self, "method")
            else None
        )
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _notes=(
            self.notes
            if hasattr(self, "notes")
            else None
        )
        _transaction_id=(
            self.transaction_id
            if hasattr(self, "transaction_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"amount={_amount!r}, "
            f"method={_method!r}, "
            f"mtype={_mtype!r}, "
            f"notes={_notes!r}, "
            f"transaction_id={_transaction_id!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _method=(
            self.method
            if hasattr(self, "method")
            else None
        )
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _notes=(
            self.notes
            if hasattr(self, "notes")
            else None
        )
        _transaction_id=(
            self.transaction_id
            if hasattr(self, "transaction_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"amount={_amount!s}, "
            f"method={_method!s}, "
            f"mtype={_mtype!s}, "
            f"notes={_notes!s}, "
            f"transaction_id={_transaction_id!s}, "
            f")"
        )
