# coding: utf-8

"""
    BTCPay Greenfield API

    A full API to use your BTCPay Server  # noqa: E501

    OpenAPI spec version: v1
    
    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 pygreenfield.api_client import ApiClient


class AuthorizationApi(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 api_keys_authorize_get(self, **kwargs):  # noqa: E501
        """Authorize User  # noqa: E501

        Redirect the browser to this endpoint to request the user to generate an api-key with specific permissions  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_keys_authorize_get(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param list[str] permissions: The permissions to request. (See API Key authentication)
        :param str application_name: The name of your application
        :param bool strict: If permissions are specified, and strict is set to false, it will allow the user to reject some of permissions the application is requesting.
        :param bool selective_stores: If the application is requesting the CanModifyStoreSettings permission and selectiveStores is set to true, this allows the user to only grant permissions to selected stores under the user's control.
        :param str redirect: The url to redirect to after the user consents, with the query parameters appended to it: permissions, user-id, api-key. If not specified, user is redirected to their API Key list.
        :param str application_identifier: If specified, BTCPay Server will check if there is an existing API key associated with the user that also has this application identifier, redirect host AND the permissions required match(takes selectiveStores and strict into account). `applicationIdentifier` is ignored if redirect is not specified.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.api_keys_authorize_get_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.api_keys_authorize_get_with_http_info(**kwargs)  # noqa: E501
            return data

    def api_keys_authorize_get_with_http_info(self, **kwargs):  # noqa: E501
        """Authorize User  # noqa: E501

        Redirect the browser to this endpoint to request the user to generate an api-key with specific permissions  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_keys_authorize_get_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param list[str] permissions: The permissions to request. (See API Key authentication)
        :param str application_name: The name of your application
        :param bool strict: If permissions are specified, and strict is set to false, it will allow the user to reject some of permissions the application is requesting.
        :param bool selective_stores: If the application is requesting the CanModifyStoreSettings permission and selectiveStores is set to true, this allows the user to only grant permissions to selected stores under the user's control.
        :param str redirect: The url to redirect to after the user consents, with the query parameters appended to it: permissions, user-id, api-key. If not specified, user is redirected to their API Key list.
        :param str application_identifier: If specified, BTCPay Server will check if there is an existing API key associated with the user that also has this application identifier, redirect host AND the permissions required match(takes selectiveStores and strict into account). `applicationIdentifier` is ignored if redirect is not specified.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['permissions', 'application_name', 'strict', 'selective_stores', 'redirect', 'application_identifier']  # 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 api_keys_authorize_get" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'permissions' in params:
            query_params.append(('permissions', params['permissions']))  # noqa: E501
            collection_formats['permissions'] = 'multi'  # noqa: E501
        if 'application_name' in params:
            query_params.append(('applicationName', params['application_name']))  # noqa: E501
        if 'strict' in params:
            query_params.append(('strict', params['strict']))  # noqa: E501
        if 'selective_stores' in params:
            query_params.append(('selectiveStores', params['selective_stores']))  # noqa: E501
        if 'redirect' in params:
            query_params.append(('redirect', params['redirect']))  # noqa: E501
        if 'application_identifier' in params:
            query_params.append(('applicationIdentifier', params['application_identifier']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/api-keys/authorize', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)
