"""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.user_agent_2 import (
    UserAgent2,
)


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

    Attributes:
        host_name (str): The title of the hosted payment page, displayed in the
            browser’s tab. If not set, defaults to the title set in the merchant
            configuration.
        ip_address (str): URL of the merchant’s logo to be displayed in Klarna’s
            hosted payment page. If not set, defaults to the logo set in the merchant
            configuration.
        user_agent (UserAgent2): The model property of type UserAgent2.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "host_name": "hostName",
        "ip_address": "ipAddress",
        "user_agent": "userAgent",
    }

    _optionals = [
        "host_name",
        "ip_address",
        "user_agent",
    ]

    def __init__(
        self,
        host_name=APIHelper.SKIP,
        ip_address=APIHelper.SKIP,
        user_agent=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a HostedPaymentInformation instance."""
        # Initialize members of the class
        if host_name is not APIHelper.SKIP:
            self.host_name = host_name
        if ip_address is not APIHelper.SKIP:
            self.ip_address = ip_address
        if user_agent is not APIHelper.SKIP:
            self.user_agent = user_agent

        # 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
        host_name =\
            dictionary.get("hostName")\
            if dictionary.get("hostName")\
                else APIHelper.SKIP
        ip_address =\
            dictionary.get("ipAddress")\
            if dictionary.get("ipAddress")\
                else APIHelper.SKIP
        user_agent =\
            UserAgent2.from_dictionary(
                dictionary.get("userAgent"))\
                if "userAgent" 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(host_name,
                   ip_address,
                   user_agent,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _host_name=(
            self.host_name
            if hasattr(self, "host_name")
            else None
        )
        _ip_address=(
            self.ip_address
            if hasattr(self, "ip_address")
            else None
        )
        _user_agent=(
            self.user_agent
            if hasattr(self, "user_agent")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"host_name={_host_name!r}, "
            f"ip_address={_ip_address!r}, "
            f"user_agent={_user_agent!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _host_name=(
            self.host_name
            if hasattr(self, "host_name")
            else None
        )
        _ip_address=(
            self.ip_address
            if hasattr(self, "ip_address")
            else None
        )
        _user_agent=(
            self.user_agent
            if hasattr(self, "user_agent")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"host_name={_host_name!s}, "
            f"ip_address={_ip_address!s}, "
            f"user_agent={_user_agent!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
