# coding: utf-8

"""
    CardPay REST API

    Welcome to the CardPay REST API. The CardPay API uses HTTP verbs and a [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) resources endpoint structure (see more info about REST). Request and response payloads are formatted as JSON. Merchant uses API to create payments, refunds, payouts or recurrings, check or update transaction status and get information about created transactions. In API authentication process based on [OAuth 2.0](https://oauth.net/2/) standard. For recent changes see changelog section.  # noqa: E501

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


class AuthenticationApi(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 create_authentication(
        self, authentication_data_request, **kwargs
    ):  # noqa: E501
        """Create authentication  # noqa: E501

        :param AuthenticationDataRequest authentication_data_request: authenticationDataRequest (required)
        :return: AuthenticationCreateResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True

        (data) = self.create_authentication_with_http_info(
            authentication_data_request, **kwargs
        )  # noqa: E501
        return data

    def create_authentication_with_http_info(
        self, authentication_data_request, **kwargs
    ):  # noqa: E501
        """Create authentication  # noqa: E501

        :param AuthenticationDataRequest authentication_data_request: authenticationDataRequest (required)
        :return: AuthenticationCreateResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["authentication_data_request"]  # noqa: E501
        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 create_authentication" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'authentication_data_request' is set
        if (
            "authentication_data_request" not in params
            or params["authentication_data_request"] is None
        ):
            raise ValueError(
                "Missing the required parameter `authentication_data_request` when calling `create_authentication`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "authentication_data_request" in params:
            body_params = params["authentication_data_request"]
        # 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

        return self.api_client.call_api(
            "/api/authentication",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AuthenticationCreateResponse",  # noqa: E501
            _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_authentication(self, auth_id, **kwargs):  # noqa: E501
        """Get authentication information  # noqa: E501

        :param str auth_id: Authentication ID (required)
        :return: AuthenticationDataResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True

        (data) = self.get_authentication_with_http_info(auth_id, **kwargs)  # noqa: E501
        return data

    def get_authentication_with_http_info(self, auth_id, **kwargs):  # noqa: E501
        """Get authentication information  # noqa: E501

        :param str auth_id: Authentication ID (required)
        :return: AuthenticationDataResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["auth_id"]  # noqa: E501
        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_authentication" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'auth_id' is set
        if "auth_id" not in params or params["auth_id"] is None:
            raise ValueError(
                "Missing the required parameter `auth_id` when calling `get_authentication`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "auth_id" in params:
            path_params["authId"] = params["auth_id"]  # 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

        return self.api_client.call_api(
            "/api/authentication/{authId}",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AuthenticationDataResponse",  # noqa: E501
            _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 update_authentication(
        self, authentication_id, authentication_patch_request, **kwargs
    ):  # noqa: E501
        """Update authentication  # noqa: E501

        :param str authentication_id: Authentication ID (required)
        :param AuthenticationPatchRequest authentication_patch_request: authenticationPatchRequest (required)
        :return: AuthenticationUpdateResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True

        (data) = self.update_authentication_with_http_info(
            authentication_id, authentication_patch_request, **kwargs
        )  # noqa: E501
        return data

    def update_authentication_with_http_info(
        self, authentication_id, authentication_patch_request, **kwargs
    ):  # noqa: E501
        """Update authentication  # noqa: E501

        :param str authentication_id: Authentication ID (required)
        :param AuthenticationPatchRequest authentication_patch_request: authenticationPatchRequest (required)
        :return: AuthenticationUpdateResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["authentication_id", "authentication_patch_request"]  # noqa: E501
        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 update_authentication" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'authentication_id' is set
        if "authentication_id" not in params or params["authentication_id"] is None:
            raise ValueError(
                "Missing the required parameter `authentication_id` when calling `update_authentication`"
            )  # noqa: E501
        # verify the required parameter 'authentication_patch_request' is set
        if (
            "authentication_patch_request" not in params
            or params["authentication_patch_request"] is None
        ):
            raise ValueError(
                "Missing the required parameter `authentication_patch_request` when calling `update_authentication`"
            )  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "authentication_id" in params:
            path_params["authenticationId"] = params["authentication_id"]  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "authentication_patch_request" in params:
            body_params = params["authentication_patch_request"]
        # 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

        return self.api_client.call_api(
            "/api/authentication/{authenticationId}",
            "PATCH",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AuthenticationUpdateResponse",  # noqa: E501
            _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,
        )
