"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.capabilities import (
    Capabilities,
)
from cellpointapi.models.screen import Screen


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

    Information about the browser a buyer is using during their purchase.

    Attributes:
        cookie_enabled (bool): Boolean value indicating if the buyer's browser has
            enabled cookies. This should be obtained by using the browser's
            `navigator.cookieEnabled` property.
        language (str): The `navigator.language` value of the buyer's browser (as
            defined in IETF BCP 47). This should be obtained by using the browser's
            `navigator.language` property.
        screen (Screen): Buyer screen data.
        user_agent (str): The user agent value of the buyer's browser.
        capabilities (Capabilities): The model property of type Capabilities.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "cookie_enabled": "cookieEnabled",
        "language": "language",
        "screen": "screen",
        "user_agent": "userAgent",
        "capabilities": "capabilities",
    }

    def __init__(
        self,
        cookie_enabled=None,
        language=None,
        screen=None,
        user_agent=None,
        capabilities=None,
        additional_properties=None):
        """Initialize a BrowserInfo instance."""
        # Initialize members of the class
        self.cookie_enabled = cookie_enabled
        self.language = language
        self.screen = screen
        self.user_agent = user_agent
        self.capabilities = capabilities

        # 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
        cookie_enabled =\
            dictionary.get("cookieEnabled")\
            if "cookieEnabled" in dictionary.keys()\
                else None
        language =\
            dictionary.get("language")\
            if dictionary.get("language")\
                else None
        screen =\
            Screen.from_dictionary(
                dictionary.get("screen"))\
                if dictionary.get("screen") else None
        user_agent =\
            dictionary.get("userAgent")\
            if dictionary.get("userAgent")\
                else None
        capabilities =\
            Capabilities.from_dictionary(
                dictionary.get("capabilities"))\
                if dictionary.get("capabilities") else None

        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(cookie_enabled,
                   language,
                   screen,
                   user_agent,
                   capabilities,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _cookie_enabled=self.cookie_enabled
        _language=self.language
        _screen=self.screen
        _user_agent=self.user_agent
        _capabilities=self.capabilities
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"cookie_enabled={_cookie_enabled!r}, "
            f"language={_language!r}, "
            f"screen={_screen!r}, "
            f"user_agent={_user_agent!r}, "
            f"capabilities={_capabilities!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _cookie_enabled=self.cookie_enabled
        _language=self.language
        _screen=self.screen
        _user_agent=self.user_agent
        _capabilities=self.capabilities
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"cookie_enabled={_cookie_enabled!s}, "
            f"language={_language!s}, "
            f"screen={_screen!s}, "
            f"user_agent={_user_agent!s}, "
            f"capabilities={_capabilities!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
