"""paypalserversdk.

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

# ruff: noqa: E501
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.mobile_web_context import (
    MobileWebContext,
)
from paypalserversdk.models.native_app_context import (
    NativeAppContext,
)


class AppSwitchContext(object):
    """Implementation of the 'App Switch Context' model.

    Merchant provided details of the native app or mobile web browser to facilitate
    buyer's app switch to the PayPal consumer app.

    Attributes:
        native_app (NativeAppContext): Merchant provided, buyer's native app
            preferences to app switch to the PayPal consumer app.
        mobile_web (MobileWebContext): Buyer's mobile web browser context to app
            switch to the PayPal consumer app.

    """

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

    _optionals = [
        "native_app",
        "mobile_web",
    ]

    def __init__(
        self,
        native_app=APIHelper.SKIP,
        mobile_web=APIHelper.SKIP):
        """Initialize a AppSwitchContext instance."""
        # Initialize members of the class
        if native_app is not APIHelper.SKIP:
            self.native_app = native_app
        if mobile_web is not APIHelper.SKIP:
            self.mobile_web = mobile_web

    @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
        native_app =\
            NativeAppContext.from_dictionary(
                dictionary.get("native_app"))\
                if "native_app" in dictionary.keys()\
                else APIHelper.SKIP
        mobile_web =\
            MobileWebContext.from_dictionary(
                dictionary.get("mobile_web"))\
                if "mobile_web" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(native_app,
                   mobile_web)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _native_app=(
            self.native_app
            if hasattr(self, "native_app")
            else None
        )
        _mobile_web=(
            self.mobile_web
            if hasattr(self, "mobile_web")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"native_app={_native_app!r}, "
            f"mobile_web={_mobile_web!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _native_app=(
            self.native_app
            if hasattr(self, "native_app")
            else None
        )
        _mobile_web=(
            self.mobile_web
            if hasattr(self, "mobile_web")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"native_app={_native_app!s}, "
            f"mobile_web={_mobile_web!s}, "
            f")"
        )
