"""mindbodypublicapi.

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

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


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

    Attributes:
        transaction_id (int): The transaction ID.
        sale_id (int): The sale ID.
        client_id (int): The ID of the client who made the purchase.
        amount (float): The amount charged on the card
        settled (bool): Whether it is settled or not
        status (str): Status of the transaction
        transaction_time (datetime): Time of card swiped
        auth_time (datetime): Time of card authorized
        location_id (int): The ID of the location where the sale takes place.
        merchant_id (str): Merchant ID of the studio
        terminal_id (str): Terminal ID used for payment. Not applicable for CNP/Bank
        card_expiration_month (str): Expiry month of the card
        card_expiration_year (str): Expiry year of the card
        cc_last_four (str): Last 4 digits of CC
        card_type (str): Type of the card
        cc_swiped (bool): Whether card is swiped or not
        ach_last_four (str): Customer’s ACH last 4 digits

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "transaction_id": "TransactionId",
        "sale_id": "SaleId",
        "client_id": "ClientId",
        "amount": "Amount",
        "settled": "Settled",
        "status": "Status",
        "transaction_time": "TransactionTime",
        "auth_time": "AuthTime",
        "location_id": "LocationId",
        "merchant_id": "MerchantId",
        "terminal_id": "TerminalId",
        "card_expiration_month": "CardExpirationMonth",
        "card_expiration_year": "CardExpirationYear",
        "cc_last_four": "CCLastFour",
        "card_type": "CardType",
        "cc_swiped": "CCSwiped",
        "ach_last_four": "ACHLastFour",
    }

    _optionals = [
        "transaction_id",
        "sale_id",
        "client_id",
        "amount",
        "settled",
        "status",
        "transaction_time",
        "auth_time",
        "location_id",
        "merchant_id",
        "terminal_id",
        "card_expiration_month",
        "card_expiration_year",
        "cc_last_four",
        "card_type",
        "cc_swiped",
        "ach_last_four",
    ]

    def __init__(
        self,
        transaction_id=APIHelper.SKIP,
        sale_id=APIHelper.SKIP,
        client_id=APIHelper.SKIP,
        amount=APIHelper.SKIP,
        settled=APIHelper.SKIP,
        status=APIHelper.SKIP,
        transaction_time=APIHelper.SKIP,
        auth_time=APIHelper.SKIP,
        location_id=APIHelper.SKIP,
        merchant_id=APIHelper.SKIP,
        terminal_id=APIHelper.SKIP,
        card_expiration_month=APIHelper.SKIP,
        card_expiration_year=APIHelper.SKIP,
        cc_last_four=APIHelper.SKIP,
        card_type=APIHelper.SKIP,
        cc_swiped=APIHelper.SKIP,
        ach_last_four=APIHelper.SKIP):
        """Initialize a Transaction instance."""
        # Initialize members of the class
        if transaction_id is not APIHelper.SKIP:
            self.transaction_id = transaction_id
        if sale_id is not APIHelper.SKIP:
            self.sale_id = sale_id
        if client_id is not APIHelper.SKIP:
            self.client_id = client_id
        if amount is not APIHelper.SKIP:
            self.amount = amount
        if settled is not APIHelper.SKIP:
            self.settled = settled
        if status is not APIHelper.SKIP:
            self.status = status
        if transaction_time is not APIHelper.SKIP:
            self.transaction_time =\
                 APIHelper.apply_datetime_converter(
                transaction_time, APIHelper.RFC3339DateTime)\
                 if transaction_time else None
        if auth_time is not APIHelper.SKIP:
            self.auth_time =\
                 APIHelper.apply_datetime_converter(
                auth_time, APIHelper.RFC3339DateTime)\
                 if auth_time else None
        if location_id is not APIHelper.SKIP:
            self.location_id = location_id
        if merchant_id is not APIHelper.SKIP:
            self.merchant_id = merchant_id
        if terminal_id is not APIHelper.SKIP:
            self.terminal_id = terminal_id
        if card_expiration_month is not APIHelper.SKIP:
            self.card_expiration_month = card_expiration_month
        if card_expiration_year is not APIHelper.SKIP:
            self.card_expiration_year = card_expiration_year
        if cc_last_four is not APIHelper.SKIP:
            self.cc_last_four = cc_last_four
        if card_type is not APIHelper.SKIP:
            self.card_type = card_type
        if cc_swiped is not APIHelper.SKIP:
            self.cc_swiped = cc_swiped
        if ach_last_four is not APIHelper.SKIP:
            self.ach_last_four = ach_last_four

    @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
        transaction_id =\
            dictionary.get("TransactionId")\
            if dictionary.get("TransactionId")\
                else APIHelper.SKIP
        sale_id =\
            dictionary.get("SaleId")\
            if dictionary.get("SaleId")\
                else APIHelper.SKIP
        client_id =\
            dictionary.get("ClientId")\
            if dictionary.get("ClientId")\
                else APIHelper.SKIP
        amount =\
            dictionary.get("Amount")\
            if dictionary.get("Amount")\
                else APIHelper.SKIP
        settled =\
            dictionary.get("Settled")\
            if "Settled" in dictionary.keys()\
                else APIHelper.SKIP
        status =\
            dictionary.get("Status")\
            if dictionary.get("Status")\
                else APIHelper.SKIP
        transaction_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("TransactionTime")).datetime\
            if dictionary.get("TransactionTime") else APIHelper.SKIP
        auth_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("AuthTime")).datetime\
            if dictionary.get("AuthTime") else APIHelper.SKIP
        location_id =\
            dictionary.get("LocationId")\
            if dictionary.get("LocationId")\
                else APIHelper.SKIP
        merchant_id =\
            dictionary.get("MerchantId")\
            if dictionary.get("MerchantId")\
                else APIHelper.SKIP
        terminal_id =\
            dictionary.get("TerminalId")\
            if dictionary.get("TerminalId")\
                else APIHelper.SKIP
        card_expiration_month =\
            dictionary.get("CardExpirationMonth")\
            if dictionary.get("CardExpirationMonth")\
                else APIHelper.SKIP
        card_expiration_year =\
            dictionary.get("CardExpirationYear")\
            if dictionary.get("CardExpirationYear")\
                else APIHelper.SKIP
        cc_last_four =\
            dictionary.get("CCLastFour")\
            if dictionary.get("CCLastFour")\
                else APIHelper.SKIP
        card_type =\
            dictionary.get("CardType")\
            if dictionary.get("CardType")\
                else APIHelper.SKIP
        cc_swiped =\
            dictionary.get("CCSwiped")\
            if "CCSwiped" in dictionary.keys()\
                else APIHelper.SKIP
        ach_last_four =\
            dictionary.get("ACHLastFour")\
            if dictionary.get("ACHLastFour")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(transaction_id,
                   sale_id,
                   client_id,
                   amount,
                   settled,
                   status,
                   transaction_time,
                   auth_time,
                   location_id,
                   merchant_id,
                   terminal_id,
                   card_expiration_month,
                   card_expiration_year,
                   cc_last_four,
                   card_type,
                   cc_swiped,
                   ach_last_four)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _transaction_id=(
            self.transaction_id
            if hasattr(self, "transaction_id")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _settled=(
            self.settled
            if hasattr(self, "settled")
            else None
        )
        _status=(
            self.status
            if hasattr(self, "status")
            else None
        )
        _transaction_time=(
            self.transaction_time
            if hasattr(self, "transaction_time")
            else None
        )
        _auth_time=(
            self.auth_time
            if hasattr(self, "auth_time")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _merchant_id=(
            self.merchant_id
            if hasattr(self, "merchant_id")
            else None
        )
        _terminal_id=(
            self.terminal_id
            if hasattr(self, "terminal_id")
            else None
        )
        _card_expiration_month=(
            self.card_expiration_month
            if hasattr(self, "card_expiration_month")
            else None
        )
        _card_expiration_year=(
            self.card_expiration_year
            if hasattr(self, "card_expiration_year")
            else None
        )
        _cc_last_four=(
            self.cc_last_four
            if hasattr(self, "cc_last_four")
            else None
        )
        _card_type=(
            self.card_type
            if hasattr(self, "card_type")
            else None
        )
        _cc_swiped=(
            self.cc_swiped
            if hasattr(self, "cc_swiped")
            else None
        )
        _ach_last_four=(
            self.ach_last_four
            if hasattr(self, "ach_last_four")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"transaction_id={_transaction_id!r}, "
            f"sale_id={_sale_id!r}, "
            f"client_id={_client_id!r}, "
            f"amount={_amount!r}, "
            f"settled={_settled!r}, "
            f"status={_status!r}, "
            f"transaction_time={_transaction_time!r}, "
            f"auth_time={_auth_time!r}, "
            f"location_id={_location_id!r}, "
            f"merchant_id={_merchant_id!r}, "
            f"terminal_id={_terminal_id!r}, "
            f"card_expiration_month={_card_expiration_month!r}, "
            f"card_expiration_year={_card_expiration_year!r}, "
            f"cc_last_four={_cc_last_four!r}, "
            f"card_type={_card_type!r}, "
            f"cc_swiped={_cc_swiped!r}, "
            f"ach_last_four={_ach_last_four!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _transaction_id=(
            self.transaction_id
            if hasattr(self, "transaction_id")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _settled=(
            self.settled
            if hasattr(self, "settled")
            else None
        )
        _status=(
            self.status
            if hasattr(self, "status")
            else None
        )
        _transaction_time=(
            self.transaction_time
            if hasattr(self, "transaction_time")
            else None
        )
        _auth_time=(
            self.auth_time
            if hasattr(self, "auth_time")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _merchant_id=(
            self.merchant_id
            if hasattr(self, "merchant_id")
            else None
        )
        _terminal_id=(
            self.terminal_id
            if hasattr(self, "terminal_id")
            else None
        )
        _card_expiration_month=(
            self.card_expiration_month
            if hasattr(self, "card_expiration_month")
            else None
        )
        _card_expiration_year=(
            self.card_expiration_year
            if hasattr(self, "card_expiration_year")
            else None
        )
        _cc_last_four=(
            self.cc_last_four
            if hasattr(self, "cc_last_four")
            else None
        )
        _card_type=(
            self.card_type
            if hasattr(self, "card_type")
            else None
        )
        _cc_swiped=(
            self.cc_swiped
            if hasattr(self, "cc_swiped")
            else None
        )
        _ach_last_four=(
            self.ach_last_four
            if hasattr(self, "ach_last_four")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"transaction_id={_transaction_id!s}, "
            f"sale_id={_sale_id!s}, "
            f"client_id={_client_id!s}, "
            f"amount={_amount!s}, "
            f"settled={_settled!s}, "
            f"status={_status!s}, "
            f"transaction_time={_transaction_time!s}, "
            f"auth_time={_auth_time!s}, "
            f"location_id={_location_id!s}, "
            f"merchant_id={_merchant_id!s}, "
            f"terminal_id={_terminal_id!s}, "
            f"card_expiration_month={_card_expiration_month!s}, "
            f"card_expiration_year={_card_expiration_year!s}, "
            f"cc_last_four={_cc_last_four!s}, "
            f"card_type={_card_type!s}, "
            f"cc_swiped={_cc_swiped!s}, "
            f"ach_last_four={_ach_last_four!s}, "
            f")"
        )
