"""paypalserversdk.

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

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


class ProcessorResponse(object):
    """Implementation of the 'Processor Response' model.

    The processor response information for payment requests, such as direct credit
    card transactions.

    Attributes:
        avs_code (AvsCode): The address verification code for Visa, Discover,
            Mastercard, or American Express transactions.
        cvv_code (CvvCode): The card verification value code for for Visa, Discover,
            Mastercard, or American Express.
        response_code (ProcessorResponseCode): Processor response code for the
            non-PayPal payment processor errors.
        payment_advice_code (PaymentAdviceCode): The declined payment transactions
            might have payment advice codes. The card networks, like Visa and
            Mastercard, return payment advice codes.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "avs_code": "avs_code",
        "cvv_code": "cvv_code",
        "response_code": "response_code",
        "payment_advice_code": "payment_advice_code",
    }

    _optionals = [
        "avs_code",
        "cvv_code",
        "response_code",
        "payment_advice_code",
    ]

    def __init__(
        self,
        avs_code=APIHelper.SKIP,
        cvv_code=APIHelper.SKIP,
        response_code=APIHelper.SKIP,
        payment_advice_code=APIHelper.SKIP):
        """Initialize a ProcessorResponse instance."""
        # Initialize members of the class
        if avs_code is not APIHelper.SKIP:
            self.avs_code = avs_code
        if cvv_code is not APIHelper.SKIP:
            self.cvv_code = cvv_code
        if response_code is not APIHelper.SKIP:
            self.response_code = response_code
        if payment_advice_code is not APIHelper.SKIP:
            self.payment_advice_code = payment_advice_code

    @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
        avs_code =\
            dictionary.get("avs_code")\
            if dictionary.get("avs_code")\
                else APIHelper.SKIP
        cvv_code =\
            dictionary.get("cvv_code")\
            if dictionary.get("cvv_code")\
                else APIHelper.SKIP
        response_code =\
            dictionary.get("response_code")\
            if dictionary.get("response_code")\
                else APIHelper.SKIP
        payment_advice_code =\
            dictionary.get("payment_advice_code")\
            if dictionary.get("payment_advice_code")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(avs_code,
                   cvv_code,
                   response_code,
                   payment_advice_code)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _avs_code=(
            self.avs_code
            if hasattr(self, "avs_code")
            else None
        )
        _cvv_code=(
            self.cvv_code
            if hasattr(self, "cvv_code")
            else None
        )
        _response_code=(
            self.response_code
            if hasattr(self, "response_code")
            else None
        )
        _payment_advice_code=(
            self.payment_advice_code
            if hasattr(self, "payment_advice_code")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"avs_code={_avs_code!r}, "
            f"cvv_code={_cvv_code!r}, "
            f"response_code={_response_code!r}, "
            f"payment_advice_code={_payment_advice_code!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _avs_code=(
            self.avs_code
            if hasattr(self, "avs_code")
            else None
        )
        _cvv_code=(
            self.cvv_code
            if hasattr(self, "cvv_code")
            else None
        )
        _response_code=(
            self.response_code
            if hasattr(self, "response_code")
            else None
        )
        _payment_advice_code=(
            self.payment_advice_code
            if hasattr(self, "payment_advice_code")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"avs_code={_avs_code!s}, "
            f"cvv_code={_cvv_code!s}, "
            f"response_code={_response_code!s}, "
            f"payment_advice_code={_payment_advice_code!s}, "
            f")"
        )
