"""paypalserversdk.

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

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


class NativeAppContext(object):
    """Implementation of the 'Native App Context' model.

    Merchant provided, buyer's native app preferences to app switch to the PayPal
    consumer app.

    Attributes:
        os_type (OsType): Operating System type of the device that the buyer is using.
        os_version (str): Operating System version of the device that the buyer is
            using.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "os_type": "os_type",
        "os_version": "os_version",
    }

    _optionals = [
        "os_type",
        "os_version",
    ]

    def __init__(
        self,
        os_type=APIHelper.SKIP,
        os_version=APIHelper.SKIP):
        """Initialize a NativeAppContext instance."""
        # Initialize members of the class
        if os_type is not APIHelper.SKIP:
            self.os_type = os_type
        if os_version is not APIHelper.SKIP:
            self.os_version = os_version

    @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
        os_type =\
            dictionary.get("os_type")\
            if dictionary.get("os_type")\
                else APIHelper.SKIP
        os_version =\
            dictionary.get("os_version")\
            if dictionary.get("os_version")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(os_type,
                   os_version)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _os_type=(
            self.os_type
            if hasattr(self, "os_type")
            else None
        )
        _os_version=(
            self.os_version
            if hasattr(self, "os_version")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"os_type={_os_type!r}, "
            f"os_version={_os_version!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _os_type=(
            self.os_type
            if hasattr(self, "os_type")
            else None
        )
        _os_version=(
            self.os_version
            if hasattr(self, "os_version")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"os_type={_os_type!s}, "
            f"os_version={_os_version!s}, "
            f")"
        )
