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

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper


class MobileWebContext(object):

    """Implementation of the 'Mobile Web Context' model.

    Buyer's mobile web browser context to app switch to the PayPal consumer
    app.

    Attributes:
        return_flow (MobileReturnFlow): Merchant preference on how the buyer
            can navigate back to merchant website post approving the
            transaction on the PayPal App.
        buyer_user_agent (str): User agent from the request originating from
            the buyer's device. This will be used to identify the buyer's
            operating system and browser versions. NOTE: Merchants must not
            alter or modify the buyer's device user agent.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "return_flow": 'return_flow',
        "buyer_user_agent": 'buyer_user_agent'
    }

    _optionals = [
        'return_flow',
        'buyer_user_agent',
    ]

    def __init__(self,
                 return_flow='AUTO',
                 buyer_user_agent=APIHelper.SKIP):
        """Constructor for the MobileWebContext class"""

        # Initialize members of the class
        self.return_flow = return_flow 
        if buyer_user_agent is not APIHelper.SKIP:
            self.buyer_user_agent = buyer_user_agent 

    @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
        return_flow = dictionary.get("return_flow") if dictionary.get("return_flow") else 'AUTO'
        buyer_user_agent = dictionary.get("buyer_user_agent") if dictionary.get("buyer_user_agent") else APIHelper.SKIP
        # Return an object of this model
        return cls(return_flow,
                   buyer_user_agent)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'return_flow={(self.return_flow if hasattr(self, "return_flow") else None)!r}, '
                f'buyer_user_agent={(self.buyer_user_agent if hasattr(self, "buyer_user_agent") else None)!r})')

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