# -*- coding: utf-8 -*-

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
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):
        """Constructor for the AppSwitchContext class"""

        # 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):
        """Creates 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 (f'{self.__class__.__name__}('
                f'native_app={(self.native_app if hasattr(self, "native_app") else None)!r}, '
                f'mobile_web={(self.mobile_web if hasattr(self, "mobile_web") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'native_app={(self.native_app if hasattr(self, "native_app") else None)!s}, '
                f'mobile_web={(self.mobile_web if hasattr(self, "mobile_web") else None)!s})')
