# 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 ReportsApiControllerApi(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 g_et_reports(self, id, **kwargs):  # noqa: E501
        """Gets actual state of processing of requested settlement reports  # noqa: E501

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

        (data) = self.g_et_reports_with_http_info(id, **kwargs)  # noqa: E501
        return data

    def g_et_reports_with_http_info(self, id, **kwargs):  # noqa: E501
        """Gets actual state of processing of requested settlement reports  # noqa: E501

        :param str id: id (required)
        :return: ReportsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if "id" in params:
            path_params["id"] = params["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(
            ["*/*"]
        )  # noqa: E501

        return self.api_client.call_api(
            "/api/reports/{id}",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="ReportsResponse",  # 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 g_et_reports_content(self, file_id, **kwargs):  # noqa: E501
        """Download prepared file: single report by id or all reports collected into archive by sample id  # noqa: E501

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

        (data) = self.g_et_reports_content_with_http_info(
            file_id, **kwargs
        )  # noqa: E501
        return data

    def g_et_reports_content_with_http_info(self, file_id, **kwargs):  # noqa: E501
        """Download prepared file: single report by id or all reports collected into archive by sample id  # noqa: E501

        :param str file_id: file_id (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if "file_id" in params:
            query_params.append(("file_id", params["file_id"]))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        return self.api_client.call_api(
            "/api/reports/download",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="str",  # 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 p_ost_reports(self, request, **kwargs):  # noqa: E501
        """Starts preparation of settlement reports for merchants  # noqa: E501

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

        (data) = self.p_ost_reports_with_http_info(request, **kwargs)  # noqa: E501
        return data

    def p_ost_reports_with_http_info(self, request, **kwargs):  # noqa: E501
        """Starts preparation of settlement reports for merchants  # noqa: E501

        :param ReportsRequest request: request (required)
        :return: ReportsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "request" in params:
            body_params = params["request"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["*/*"]
        )  # 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/reports",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="ReportsResponse",  # 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,
        )
