# coding: utf-8

"""
    Developer Registration API

    <span class=\"tablenote\"><b>Note:</b> The Client Registration API is not intended for use by developers who have previously registered for a Developer Account on the eBay platform.</span><br/>The Client Registration API provides Dynamic Client Registration for regulated Third Party Providers (TPPs) who are, or will be, engaged in financial transactions on behalf of individuals domiciled in the EU/UK. This is required by the EU's Second Payment Services Directive (PSD2) which requires all regulated Account Servicing Payment Service Providers (ASPSPs) to provide secure APIs to access account and payment services on behalf of account holders.<br/><br/>A successful registration response returns a <b>HTTP 201 Created</b> status code with a JSON payload [RFC7519] that includes registration information.  # noqa: E501

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


class RegisterApi(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 register_client(self, body, **kwargs):  # noqa: E501
        """register_client  # noqa: E501

        <span class=\"tablenote\"><b>Note:</b> The Client Registration API is not intended for use by developers who have previously registered for a Developer Account on the eBay platform.</span><br/>This call registers a new third party financial application with eBay.<br/><br/><div class=\"msgbox_important\"><p class=\"msgbox_importantInDiv\" data-mc-autonum=\"&lt;b&gt;&lt;span style=&quot;color: #dd1e31;&quot; class=&quot;mcFormatColor&quot;&gt;Important! &lt;/span&gt;&lt;/b&gt;\"><span class=\"autonumber\"><span><b><span style=\"color: #dd1e31;\" class=\"mcFormatColor\">Important!</span></b></span></span> When calling the <b>registerClient</b> method, Third Party Providers (TPPs) are required to pass their valid eIDAS certificate to eBay via Mutual Transport Layer Security (MTLS) handshake <i>Certificate Request</i> messages.</p></div><br/>A successful call returns an HTTP status code of <b>201 Created</b> and the response payload.<h4>Registering multiple applications</h4>A regulated third party provider (identified by a unique <i>organizationIdentifier</i>) may register up to 15 different applications with eBay provided the unique <a href=\"#request.software_id \">software_id</a> for each application is passed in at the time of registration.<br/><br/>Each <b>registerClient</b> call that passes in a unique <a href=\"#request.software_id \">software_id</a> will generate new <a href=\"#response.client_id \">client_id</a> and <a href=\"#response.client_secret \">client_secret</a> keypairs.<br/><br/>If a third party provider calls <b>registerClient</b> using a previously registered <a href=\"#request.software_id \">software_id</a>, the existing <a href=\"#response.client_id \">client_id</a> and <a href=\"#response.client_secret \">client_secret</a> keypairs are returned.<br/><br/><span class=\"tablenote\"><b>Note:</b> For additional information about using an <i>organizationIdentifier</i>, refer to the following sections of <a href=\"https://www.etsi.org/deliver/etsi_ts/119400_119499/119495/01.05.01_60/ts_119495v010501p.pdf \" target=\"_blank \">ETSI Technical Specification 119 495</a><ul><li>Section 5.2.1: Authorization Number or other recognized identifier for Open Banking;</li><li>Section 5.4: Profile Requirements for Digital Signatures.</li></ul></span>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.register_client(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param ClientSettings body: This container stores information about the third party provider's financial application that is being registered. (required)
        :return: ClientDetails
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.register_client_with_http_info(body, **kwargs)  # noqa: E501
        else:
            (data) = self.register_client_with_http_info(body, **kwargs)  # noqa: E501
            return data

    def register_client_with_http_info(self, body, **kwargs):  # noqa: E501
        """register_client  # noqa: E501

        <span class=\"tablenote\"><b>Note:</b> The Client Registration API is not intended for use by developers who have previously registered for a Developer Account on the eBay platform.</span><br/>This call registers a new third party financial application with eBay.<br/><br/><div class=\"msgbox_important\"><p class=\"msgbox_importantInDiv\" data-mc-autonum=\"&lt;b&gt;&lt;span style=&quot;color: #dd1e31;&quot; class=&quot;mcFormatColor&quot;&gt;Important! &lt;/span&gt;&lt;/b&gt;\"><span class=\"autonumber\"><span><b><span style=\"color: #dd1e31;\" class=\"mcFormatColor\">Important!</span></b></span></span> When calling the <b>registerClient</b> method, Third Party Providers (TPPs) are required to pass their valid eIDAS certificate to eBay via Mutual Transport Layer Security (MTLS) handshake <i>Certificate Request</i> messages.</p></div><br/>A successful call returns an HTTP status code of <b>201 Created</b> and the response payload.<h4>Registering multiple applications</h4>A regulated third party provider (identified by a unique <i>organizationIdentifier</i>) may register up to 15 different applications with eBay provided the unique <a href=\"#request.software_id \">software_id</a> for each application is passed in at the time of registration.<br/><br/>Each <b>registerClient</b> call that passes in a unique <a href=\"#request.software_id \">software_id</a> will generate new <a href=\"#response.client_id \">client_id</a> and <a href=\"#response.client_secret \">client_secret</a> keypairs.<br/><br/>If a third party provider calls <b>registerClient</b> using a previously registered <a href=\"#request.software_id \">software_id</a>, the existing <a href=\"#response.client_id \">client_id</a> and <a href=\"#response.client_secret \">client_secret</a> keypairs are returned.<br/><br/><span class=\"tablenote\"><b>Note:</b> For additional information about using an <i>organizationIdentifier</i>, refer to the following sections of <a href=\"https://www.etsi.org/deliver/etsi_ts/119400_119499/119495/01.05.01_60/ts_119495v010501p.pdf \" target=\"_blank \">ETSI Technical Specification 119 495</a><ul><li>Section 5.2.1: Authorization Number or other recognized identifier for Open Banking;</li><li>Section 5.4: Profile Requirements for Digital Signatures.</li></ul></span>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.register_client_with_http_info(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param ClientSettings body: This container stores information about the third party provider's financial application that is being registered. (required)
        :return: ClientDetails
                 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 register_client" % 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 `register_client`")  # 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 = []  # noqa: E501

        return self.api_client.call_api(
            '/client/register', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ClientDetails',  # 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)
