"""paypalserversdk.

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

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


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

    Reference values used by the card network to identify a transaction.

    Attributes:
        id (str): Transaction reference id returned by the scheme. For Visa and Amex,
            this is the "Tran id" field in response. For MasterCard, this is the
            "BankNet reference id" field in response. For Discover, this is the
            "NRID" field in response. The pattern we expect for this field from
            Visa/Amex/CB/Discover is numeric, Mastercard/BNPP is alphanumeric and
            Paysecure is alphanumeric with special character -.
        date (str): The date that the transaction was authorized by the scheme. This
            field may not be returned for all networks. MasterCard refers to this
            field as "BankNet reference date". For some specific networks, such as
            MasterCard and Discover, this date field is mandatory when the
            `previous_network_transaction_reference_id` is passed.
        network (CardBrand): The card network or brand. Applies to credit, debit,
            gift, and payment cards.
        acquirer_reference_number (str): Reference ID issued for the card
            transaction. This ID can be used to track the transaction across
            processors, card brands and issuing banks.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "id",
        "date": "date",
        "network": "network",
        "acquirer_reference_number": "acquirer_reference_number",
    }

    _optionals = [
        "id",
        "date",
        "network",
        "acquirer_reference_number",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        date=APIHelper.SKIP,
        network=APIHelper.SKIP,
        acquirer_reference_number=APIHelper.SKIP):
        """Initialize a NetworkTransaction instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if date is not APIHelper.SKIP:
            self.date = date
        if network is not APIHelper.SKIP:
            self.network = network
        if acquirer_reference_number is not APIHelper.SKIP:
            self.acquirer_reference_number = acquirer_reference_number

    @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
        date =\
            dictionary.get("date")\
            if dictionary.get("date")\
                else APIHelper.SKIP
        network =\
            dictionary.get("network")\
            if dictionary.get("network")\
                else APIHelper.SKIP
        acquirer_reference_number =\
            dictionary.get("acquirer_reference_number")\
            if dictionary.get("acquirer_reference_number")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   date,
                   network,
                   acquirer_reference_number)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _date=(
            self.date
            if hasattr(self, "date")
            else None
        )
        _network=(
            self.network
            if hasattr(self, "network")
            else None
        )
        _acquirer_reference_number=(
            self.acquirer_reference_number
            if hasattr(self, "acquirer_reference_number")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"date={_date!r}, "
            f"network={_network!r}, "
            f"acquirer_reference_number={_acquirer_reference_number!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _date=(
            self.date
            if hasattr(self, "date")
            else None
        )
        _network=(
            self.network
            if hasattr(self, "network")
            else None
        )
        _acquirer_reference_number=(
            self.acquirer_reference_number
            if hasattr(self, "acquirer_reference_number")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"date={_date!s}, "
            f"network={_network!s}, "
            f"acquirer_reference_number={_acquirer_reference_number!s}, "
            f")"
        )
