"""visaacceptancemergedspec.

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

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)


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

    Attributes:
        code (str): - Merchant should update their retry logic to ensure retry is not
            attempted for the cards for which Issuer won’t approve the transactions
            and where the retry is allowed. - Card Processing Associations provides
            this data which is being passed through in the following data element
            irrespective of the Card Associations.   Usage of this data must be
            always associated with the Card Associations card types for merchant
            processing retry logic. - In additions to the Merchant Advice code,
            Associations also provides the decline response codes which provides the
            reason for decline.  Association response code will be a pass-through
            value.  #### Processors supported:   - HSBC   - Barclays   - FDC Nash   -
            FDI Global   - Elavon America   - VPC   - Rede   - Payment tech Salem
            #### Possible values: | Card Type   | Advice Code   |  Description
            | | ----------- | ------------- |
            ------------------------------------------- | | VISA        | 1
            | Issuer never approves                       | | VISA        | 2
            | Issuer cannot approve at this time          | | VISA        | 3
            | Data quality/revalidate payment information | | MasterCard  | 01
            | New account information available           | | MasterCard  | 02
            | Try Again Later                             | | MasterCard  | 03
            | Do Not Try Again                            | | MasterCard  | 04
            | Token not supported                         | | MasterCard  | 21
            | Do not honor                                | | MasterCard  | 22
            | Merchant does not qualify for product code  | | MasterCard  | 24
            | Retry after 1 hour                          | | MasterCard  | 25
            | Retry after 24 hours                        | | MasterCard  | 26
            | Retry after 2 days                          | | MasterCard  | 27
            | Retry after 4 days                          | | MasterCard  | 28
            | Retry after 6 days                          | | MasterCard  | 29
            | Retry after 8 days                          | | MasterCard  | 30
            | Retry after 10 days                         | | MasterCard  | 40
            | Consumer non-reloadable prepaid card        | | MasterCard  | 41
            | Consumer single-use virtual card number     | | MasterCard  | 42
            | Sanctions score exceeds threshold value     | | MasterCard  | 99
            | Do Not Try Again                            |
        code_raw (str): Raw merchant advice code sent directly from the processor.
            This field is used only for Mastercard.  #### Visa Acceptance through
            VisaNet The value for this field corresponds to the following data in the
            TC 33 capture file1: - Record: CP01 TCR7 - Position: 96-99 - Field:
            Response Data-Merchant Advice Code
        name_match (str): #### Visa Platform Connect The field contains will contain
            the Account Name Request Result for zero amount Authorization request.
            Valid values are:  00 = Name Match Performed 01 = Name Match not
            Performed 02 = Name Match not supported
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "code": "code",
        "code_raw": "codeRaw",
        "name_match": "nameMatch",
    }

    _optionals = [
        "code",
        "code_raw",
        "name_match",
    ]

    def __init__(
        self,
        code=APIHelper.SKIP,
        code_raw=APIHelper.SKIP,
        name_match=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a MerchantAdvice instance."""
        # Initialize members of the class
        if code is not APIHelper.SKIP:
            self.code = code
        if code_raw is not APIHelper.SKIP:
            self.code_raw = code_raw
        if name_match is not APIHelper.SKIP:
            self.name_match = name_match

        # 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
        code =\
            dictionary.get("code")\
            if dictionary.get("code")\
                else APIHelper.SKIP
        code_raw =\
            dictionary.get("codeRaw")\
            if dictionary.get("codeRaw")\
                else APIHelper.SKIP
        name_match =\
            dictionary.get("nameMatch")\
            if dictionary.get("nameMatch")\
                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(code,
                   code_raw,
                   name_match,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _code=(
            self.code
            if hasattr(self, "code")
            else None
        )
        _code_raw=(
            self.code_raw
            if hasattr(self, "code_raw")
            else None
        )
        _name_match=(
            self.name_match
            if hasattr(self, "name_match")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"code={_code!r}, "
            f"code_raw={_code_raw!r}, "
            f"name_match={_name_match!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _code=(
            self.code
            if hasattr(self, "code")
            else None
        )
        _code_raw=(
            self.code_raw
            if hasattr(self, "code_raw")
            else None
        )
        _name_match=(
            self.name_match
            if hasattr(self, "name_match")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"code={_code!s}, "
            f"code_raw={_code_raw!s}, "
            f"name_match={_name_match!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
