"""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.browser_info import (
    BrowserInfo,
)
from cellpointapi.models.cpu import Cpu
from cellpointapi.models.fingerprint import (
    Fingerprint,
)
from cellpointapi.models.network_info import (
    NetworkInfo,
)


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

    Buyer fingerprint data.

    Attributes:
        device_os (DeviceOs): The device operating system.
        cpu (Cpu): Get type of CPU architecture from user-agent string.
        browser_info (BrowserInfo): Information about the browser a buyer is using
            during their purchase.
        network_info (NetworkInfo): Information about the users ip.
        fingerprints (List[Fingerprint]): The model property of type
            List[Fingerprint].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "device_os": "deviceOs",
        "cpu": "cpu",
        "browser_info": "browserInfo",
        "network_info": "networkInfo",
        "fingerprints": "fingerprints",
    }

    _optionals = [
        "device_os",
        "cpu",
        "browser_info",
        "network_info",
        "fingerprints",
    ]

    def __init__(
        self,
        device_os=APIHelper.SKIP,
        cpu=APIHelper.SKIP,
        browser_info=APIHelper.SKIP,
        network_info=APIHelper.SKIP,
        fingerprints=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a BuyerFingerprint instance."""
        # Initialize members of the class
        if device_os is not APIHelper.SKIP:
            self.device_os = device_os
        if cpu is not APIHelper.SKIP:
            self.cpu = cpu
        if browser_info is not APIHelper.SKIP:
            self.browser_info = browser_info
        if network_info is not APIHelper.SKIP:
            self.network_info = network_info
        if fingerprints is not APIHelper.SKIP:
            self.fingerprints = fingerprints

        # 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
        device_os =\
            dictionary.get("deviceOs")\
            if dictionary.get("deviceOs")\
                else APIHelper.SKIP
        cpu =\
            Cpu.from_dictionary(
                dictionary.get("cpu"))\
                if "cpu" in dictionary.keys()\
                else APIHelper.SKIP
        browser_info =\
            BrowserInfo.from_dictionary(
                dictionary.get("browserInfo"))\
                if "browserInfo" in dictionary.keys()\
                else APIHelper.SKIP
        network_info =\
            NetworkInfo.from_dictionary(
                dictionary.get("networkInfo"))\
                if "networkInfo" in dictionary.keys()\
                else APIHelper.SKIP
        fingerprints = None
        if dictionary.get("fingerprints") is not None:
            fingerprints = [
                Fingerprint.from_dictionary(x)
                    for x in dictionary.get("fingerprints")
            ]
        else:
            fingerprints = 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(device_os,
                   cpu,
                   browser_info,
                   network_info,
                   fingerprints,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _device_os=(
            self.device_os
            if hasattr(self, "device_os")
            else None
        )
        _cpu=(
            self.cpu
            if hasattr(self, "cpu")
            else None
        )
        _browser_info=(
            self.browser_info
            if hasattr(self, "browser_info")
            else None
        )
        _network_info=(
            self.network_info
            if hasattr(self, "network_info")
            else None
        )
        _fingerprints=(
            self.fingerprints
            if hasattr(self, "fingerprints")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"device_os={_device_os!r}, "
            f"cpu={_cpu!r}, "
            f"browser_info={_browser_info!r}, "
            f"network_info={_network_info!r}, "
            f"fingerprints={_fingerprints!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _device_os=(
            self.device_os
            if hasattr(self, "device_os")
            else None
        )
        _cpu=(
            self.cpu
            if hasattr(self, "cpu")
            else None
        )
        _browser_info=(
            self.browser_info
            if hasattr(self, "browser_info")
            else None
        )
        _network_info=(
            self.network_info
            if hasattr(self, "network_info")
            else None
        )
        _fingerprints=(
            self.fingerprints
            if hasattr(self, "fingerprints")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"device_os={_device_os!s}, "
            f"cpu={_cpu!s}, "
            f"browser_info={_browser_info!s}, "
            f"network_info={_network_info!s}, "
            f"fingerprints={_fingerprints!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
