"""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_descriptor_11 import (
    MerchantDescriptor11,
)


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

    Attributes:
        merchant_descriptor (MerchantDescriptor11): The model property of type
            MerchantDescriptor11.
        cancel_url (str): customer would be redirected to this url based on the
            decision of the transaction
        success_url (str): customer would be redirected to this url based on the
            decision of the transaction
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "merchant_descriptor": "merchantDescriptor",
        "cancel_url": "cancelUrl",
        "success_url": "successUrl",
    }

    _optionals = [
        "merchant_descriptor",
        "cancel_url",
        "success_url",
    ]

    def __init__(
        self,
        merchant_descriptor=APIHelper.SKIP,
        cancel_url=APIHelper.SKIP,
        success_url=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a MerchantInformation16 instance."""
        # Initialize members of the class
        if merchant_descriptor is not APIHelper.SKIP:
            self.merchant_descriptor = merchant_descriptor
        if cancel_url is not APIHelper.SKIP:
            self.cancel_url = cancel_url
        if success_url is not APIHelper.SKIP:
            self.success_url = success_url

        # 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
        merchant_descriptor =\
            MerchantDescriptor11.from_dictionary(
                dictionary.get("merchantDescriptor"))\
                if "merchantDescriptor" in dictionary.keys()\
                else APIHelper.SKIP
        cancel_url =\
            dictionary.get("cancelUrl")\
            if dictionary.get("cancelUrl")\
                else APIHelper.SKIP
        success_url =\
            dictionary.get("successUrl")\
            if dictionary.get("successUrl")\
                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(merchant_descriptor,
                   cancel_url,
                   success_url,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _merchant_descriptor=(
            self.merchant_descriptor
            if hasattr(self, "merchant_descriptor")
            else None
        )
        _cancel_url=(
            self.cancel_url
            if hasattr(self, "cancel_url")
            else None
        )
        _success_url=(
            self.success_url
            if hasattr(self, "success_url")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"merchant_descriptor={_merchant_descriptor!r}, "
            f"cancel_url={_cancel_url!r}, "
            f"success_url={_success_url!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _merchant_descriptor=(
            self.merchant_descriptor
            if hasattr(self, "merchant_descriptor")
            else None
        )
        _cancel_url=(
            self.cancel_url
            if hasattr(self, "cancel_url")
            else None
        )
        _success_url=(
            self.success_url
            if hasattr(self, "success_url")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"merchant_descriptor={_merchant_descriptor!s}, "
            f"cancel_url={_cancel_url!s}, "
            f"success_url={_success_url!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
