# coding: utf-8

"""
    ThingsBoard REST API

     ThingsBoard Professional Edition IoT platform REST API documentation.  # noqa: E501

    OpenAPI spec version: 3.7.0PE-SNAPSHOT
    Contact: info@thingsboard.io
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from tb_rest_client.api_client import ApiClient


class MobileApplicationControllerApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def get_application_redirect(self, user_agent, **kwargs):  # noqa: E501
        """getApplicationRedirect  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_application_redirect(user_agent, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_agent: (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_application_redirect_with_http_info(user_agent, **kwargs)  # noqa: E501
        else:
            (data) = self.get_application_redirect_with_http_info(user_agent, **kwargs)  # noqa: E501
            return data

    def get_application_redirect_with_http_info(self, user_agent, **kwargs):  # noqa: E501
        """getApplicationRedirect  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_application_redirect_with_http_info(user_agent, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_agent: (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_agent']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_application_redirect" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_agent' is set
        if ('user_agent' not in params or
                params['user_agent'] is None):
            raise ValueError("Missing the required parameter `user_agent` when calling `get_application_redirect`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}
        if 'user_agent' in params:
            header_params['User-Agent'] = params['user_agent']  # noqa: E501

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/api/noauth/qr', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='object',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_merged_mobile_app_settings(self, **kwargs):  # noqa: E501
        """Get QR code configuration for home page (getMobileAppQrCodeConfig)  # noqa: E501

        The response payload contains ui configuration of qr code  Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_merged_mobile_app_settings(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: MobileAppSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_merged_mobile_app_settings_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_merged_mobile_app_settings_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_merged_mobile_app_settings_with_http_info(self, **kwargs):  # noqa: E501
        """Get QR code configuration for home page (getMobileAppQrCodeConfig)  # noqa: E501

        The response payload contains ui configuration of qr code  Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_merged_mobile_app_settings_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: MobileAppSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_merged_mobile_app_settings" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/mobile/app/settings/merged', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='MobileAppSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_mobile_app_deep_link(self, **kwargs):  # noqa: E501
        """Get the deep link to the associated mobile application (getMobileAppDeepLink)  # noqa: E501

        Fetch the url that takes user to linked mobile application   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_mobile_app_deep_link(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_mobile_app_deep_link_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_mobile_app_deep_link_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_mobile_app_deep_link_with_http_info(self, **kwargs):  # noqa: E501
        """Get the deep link to the associated mobile application (getMobileAppDeepLink)  # noqa: E501

        Fetch the url that takes user to linked mobile application   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_mobile_app_deep_link_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_mobile_app_deep_link" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/mobile/deepLink', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_mobile_app_settings(self, **kwargs):  # noqa: E501
        """Get Mobile application settings (getMobileAppSettings)  # noqa: E501

        The response payload contains configuration for android/iOS applications and platform qr code widget settings.  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_mobile_app_settings(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: MobileAppSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_mobile_app_settings_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_mobile_app_settings_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_mobile_app_settings_with_http_info(self, **kwargs):  # noqa: E501
        """Get Mobile application settings (getMobileAppSettings)  # noqa: E501

        The response payload contains configuration for android/iOS applications and platform qr code widget settings.  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_mobile_app_settings_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: MobileAppSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_mobile_app_settings" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/mobile/app/settings', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='MobileAppSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_user_token_by_mobile_secret(self, secret, **kwargs):  # noqa: E501
        """Get User Token (getUserTokenByMobileSecret)  # noqa: E501

        Returns the token of the User based on the provided secret key.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_user_token_by_mobile_secret(secret, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str secret: A string value representing short-lived secret key (required)
        :return: JwtPair
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_user_token_by_mobile_secret_with_http_info(secret, **kwargs)  # noqa: E501
        else:
            (data) = self.get_user_token_by_mobile_secret_with_http_info(secret, **kwargs)  # noqa: E501
            return data

    def get_user_token_by_mobile_secret_with_http_info(self, secret, **kwargs):  # noqa: E501
        """Get User Token (getUserTokenByMobileSecret)  # noqa: E501

        Returns the token of the User based on the provided secret key.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_user_token_by_mobile_secret_with_http_info(secret, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str secret: A string value representing short-lived secret key (required)
        :return: JwtPair
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['secret']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_user_token_by_mobile_secret" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'secret' is set
        if ('secret' not in params or
                params['secret'] is None):
            raise ValueError("Missing the required parameter `secret` when calling `get_user_token_by_mobile_secret`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'secret' in params:
            path_params['secret'] = params['secret']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/api/noauth/qr/{secret}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='JwtPair',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def save_mobile_app_settings(self, body, **kwargs):  # noqa: E501
        """Create Or Update the Mobile application settings (saveMobileAppSettings)  # noqa: E501

        The request payload contains configuration for android/iOS applications and platform qr code widget settings.  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.save_mobile_app_settings(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param MobileAppSettings body: (required)
        :return: MobileAppSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.save_mobile_app_settings_with_http_info(body, **kwargs)  # noqa: E501
        else:
            (data) = self.save_mobile_app_settings_with_http_info(body, **kwargs)  # noqa: E501
            return data

    def save_mobile_app_settings_with_http_info(self, body, **kwargs):  # noqa: E501
        """Create Or Update the Mobile application settings (saveMobileAppSettings)  # noqa: E501

        The request payload contains configuration for android/iOS applications and platform qr code widget settings.  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.save_mobile_app_settings_with_http_info(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param MobileAppSettings body: (required)
        :return: MobileAppSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method save_mobile_app_settings" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'body' is set
        if ('body' not in params or
                params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `save_mobile_app_settings`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/mobile/app/settings', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='MobileAppSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
