"""visaacceptancemergedspec.

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

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.models.merchant_advice import (
    MerchantAdvice,
)
from visaacceptancemergedspec.models.seller_protection import (
    SellerProtection,
)


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

    Attributes:
        approval_code (str): Authorization code. Returned only when the processor
            returns this value.  The length of this value depends on your processor.
            Returned by authorization service.  #### PIN debit Authorization code
            that is returned by the processor.  Returned by PIN debit credit.  ####
            Elavon Encrypted Account Number Program The returned value is OFFLINE.
            #### TSYS Acquiring Solutions The returned value for a successful zero
            amount authorization is 000000.
        transaction_id (str): Network transaction identifier (TID). You can use this
            value to identify a specific transaction when you are discussing the
            transaction with your processor. Not all processors provide this value.
            Returned by the authorization service.  #### PIN debit Transaction
            identifier generated by the processor.  Returned by PIN debit credit.
            #### GPX Processor transaction ID.  #### Cielo For Cielo, this value is
            the non-sequential unit (NSU) and is supported for all transactions. The
            value is generated by Cielo or the issuing bank.  #### Comercio Latino
            For Comercio Latino, this value is the proof of sale or non-sequential
            unit (NSU) number generated by the acquirers Cielo and Rede, or the
            issuing bank.  #### Visa Acceptance through VisaNet and GPN For details
            about this value for Visa Acceptance through VisaNet and GPN, see
            "processorInformation.networkTransactionId" in [REST API Fields](  ####
            Moneris This value identifies the transaction on a host system. It
            contains the following information: - Terminal used to process the
            transaction - Shift during which the transaction took place - Batch
            number - Transaction number within the batch You must store this value.
            If you give the customer a receipt, display this value on the receipt.
            **Example** For the value 66012345001069003: - Terminal ID = 66012345 -
            Shift number = 001 - Batch number = 069 - Transaction number = 003
        network_transaction_id (str): Same value as
            `processorInformation.transactionId`
        response_code (str): For most processors, this is the error message sent
            directly from the bank. Returned only when the processor returns this
            value.  **Important** Do not use this field to evaluate the result of the
            authorization.  #### PIN debit Response value that is returned by the
            processor or bank. **Important** Do not use this field to evaluate the
            results of the transaction request.  Returned by PIN debit credit, PIN
            debit purchase, and PIN debit reversal.  #### AIBMS If this value is
            `08`, you can accept the transaction if the customer provides you with
            identification.  #### Atos This value is the response code sent from Atos
            and it might also include the response code from the bank. Format:
            `aa,bb` with the two values separated by a comma and where: - `aa` is the
            two-digit error message from Atos. - `bb` is the optional two-digit error
            message from the bank.  #### Comercio Latino This value is the status
            code and the error or response code received from the processor separated
            by a colon. Format: [status code]:E[error code] or [status
            code]:R[response code] Example `2:R06`  #### JCN Gateway
            Processor-defined detail error code. The associated response category
            code is in the `processorInformation.responseCategoryCode` field. String
            (3)  #### paypalgateway Processor generated ID for the itemized detail.
        system_trace_audit_number (str): This field is returned only for **American
            Express Direct** and **Visa Acceptance through VisaNet**. Returned by
            authorization and incremental authorization services.  #### American
            Express Direct  System trace audit number (STAN). This value identifies
            the transaction and is useful when investigating a chargeback dispute.
            #### Visa Acceptance through VisaNet  System trace number that must be
            printed on the customer’s receipt.
        response_details (str): This field might contain information about a decline.
            This field is supported only for **Visa Acceptance through VisaNet**.
        merchant_advice (MerchantAdvice): The model property of type MerchantAdvice.
        merchant_risk_prediction (str): Mastercard is introducing the Merchant Risk
            Predict Service in the middle East/Africa Region. A newly launched
            service comprised of seven independent artificial intelligence
            (AI)-powered scores intended to augment existing merchant risk management
            practices.
        seller_protection (SellerProtection): The model property of type
            SellerProtection.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "approval_code": "approvalCode",
        "transaction_id": "transactionId",
        "network_transaction_id": "networkTransactionId",
        "response_code": "responseCode",
        "system_trace_audit_number": "systemTraceAuditNumber",
        "response_details": "responseDetails",
        "merchant_advice": "merchantAdvice",
        "merchant_risk_prediction": "merchantRiskPrediction",
        "seller_protection": "sellerProtection",
    }

    _optionals = [
        "approval_code",
        "transaction_id",
        "network_transaction_id",
        "response_code",
        "system_trace_audit_number",
        "response_details",
        "merchant_advice",
        "merchant_risk_prediction",
        "seller_protection",
    ]

    def __init__(
        self,
        approval_code=APIHelper.SKIP,
        transaction_id=APIHelper.SKIP,
        network_transaction_id=APIHelper.SKIP,
        response_code=APIHelper.SKIP,
        system_trace_audit_number=APIHelper.SKIP,
        response_details=APIHelper.SKIP,
        merchant_advice=APIHelper.SKIP,
        merchant_risk_prediction=APIHelper.SKIP,
        seller_protection=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a ProcessorInformation2 instance."""
        # Initialize members of the class
        if approval_code is not APIHelper.SKIP:
            self.approval_code = approval_code
        if transaction_id is not APIHelper.SKIP:
            self.transaction_id = transaction_id
        if network_transaction_id is not APIHelper.SKIP:
            self.network_transaction_id = network_transaction_id
        if response_code is not APIHelper.SKIP:
            self.response_code = response_code
        if system_trace_audit_number is not APIHelper.SKIP:
            self.system_trace_audit_number = system_trace_audit_number
        if response_details is not APIHelper.SKIP:
            self.response_details = response_details
        if merchant_advice is not APIHelper.SKIP:
            self.merchant_advice = merchant_advice
        if merchant_risk_prediction is not APIHelper.SKIP:
            self.merchant_risk_prediction = merchant_risk_prediction
        if seller_protection is not APIHelper.SKIP:
            self.seller_protection = seller_protection

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @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
        approval_code =\
            dictionary.get("approvalCode")\
            if dictionary.get("approvalCode")\
                else APIHelper.SKIP
        transaction_id =\
            dictionary.get("transactionId")\
            if dictionary.get("transactionId")\
                else APIHelper.SKIP
        network_transaction_id =\
            dictionary.get("networkTransactionId")\
            if dictionary.get("networkTransactionId")\
                else APIHelper.SKIP
        response_code =\
            dictionary.get("responseCode")\
            if dictionary.get("responseCode")\
                else APIHelper.SKIP
        system_trace_audit_number =\
            dictionary.get("systemTraceAuditNumber")\
            if dictionary.get("systemTraceAuditNumber")\
                else APIHelper.SKIP
        response_details =\
            dictionary.get("responseDetails")\
            if dictionary.get("responseDetails")\
                else APIHelper.SKIP
        merchant_advice =\
            MerchantAdvice.from_dictionary(
                dictionary.get("merchantAdvice"))\
                if "merchantAdvice" in dictionary.keys()\
                else APIHelper.SKIP
        merchant_risk_prediction =\
            dictionary.get("merchantRiskPrediction")\
            if dictionary.get("merchantRiskPrediction")\
                else APIHelper.SKIP
        seller_protection =\
            SellerProtection.from_dictionary(
                dictionary.get("sellerProtection"))\
                if "sellerProtection" in dictionary.keys()\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(approval_code,
                   transaction_id,
                   network_transaction_id,
                   response_code,
                   system_trace_audit_number,
                   response_details,
                   merchant_advice,
                   merchant_risk_prediction,
                   seller_protection,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _approval_code=(
            self.approval_code
            if hasattr(self, "approval_code")
            else None
        )
        _transaction_id=(
            self.transaction_id
            if hasattr(self, "transaction_id")
            else None
        )
        _network_transaction_id=(
            self.network_transaction_id
            if hasattr(self, "network_transaction_id")
            else None
        )
        _response_code=(
            self.response_code
            if hasattr(self, "response_code")
            else None
        )
        _system_trace_audit_number=(
            self.system_trace_audit_number
            if hasattr(self, "system_trace_audit_number")
            else None
        )
        _response_details=(
            self.response_details
            if hasattr(self, "response_details")
            else None
        )
        _merchant_advice=(
            self.merchant_advice
            if hasattr(self, "merchant_advice")
            else None
        )
        _merchant_risk_prediction=(
            self.merchant_risk_prediction
            if hasattr(self, "merchant_risk_prediction")
            else None
        )
        _seller_protection=(
            self.seller_protection
            if hasattr(self, "seller_protection")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"approval_code={_approval_code!r}, "
            f"transaction_id={_transaction_id!r}, "
            f"network_transaction_id={_network_transaction_id!r}, "
            f"response_code={_response_code!r}, "
            f"system_trace_audit_number={_system_trace_audit_number!r}, "
            f"response_details={_response_details!r}, "
            f"merchant_advice={_merchant_advice!r}, "
            f"merchant_risk_prediction={_merchant_risk_prediction!r}, "
            f"seller_protection={_seller_protection!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _approval_code=(
            self.approval_code
            if hasattr(self, "approval_code")
            else None
        )
        _transaction_id=(
            self.transaction_id
            if hasattr(self, "transaction_id")
            else None
        )
        _network_transaction_id=(
            self.network_transaction_id
            if hasattr(self, "network_transaction_id")
            else None
        )
        _response_code=(
            self.response_code
            if hasattr(self, "response_code")
            else None
        )
        _system_trace_audit_number=(
            self.system_trace_audit_number
            if hasattr(self, "system_trace_audit_number")
            else None
        )
        _response_details=(
            self.response_details
            if hasattr(self, "response_details")
            else None
        )
        _merchant_advice=(
            self.merchant_advice
            if hasattr(self, "merchant_advice")
            else None
        )
        _merchant_risk_prediction=(
            self.merchant_risk_prediction
            if hasattr(self, "merchant_risk_prediction")
            else None
        )
        _seller_protection=(
            self.seller_protection
            if hasattr(self, "seller_protection")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"approval_code={_approval_code!s}, "
            f"transaction_id={_transaction_id!s}, "
            f"network_transaction_id={_network_transaction_id!s}, "
            f"response_code={_response_code!s}, "
            f"system_trace_audit_number={_system_trace_audit_number!s}, "
            f"response_details={_response_details!s}, "
            f"merchant_advice={_merchant_advice!s}, "
            f"merchant_risk_prediction={_merchant_risk_prediction!s}, "
            f"seller_protection={_seller_protection!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
