"""staxfattmerchantapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: D410, E501, E101, D206
from apimatic_core.authentication.multiple.single_auth import (
    Single,
)
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter

from staxfattmerchantapi.api_helper import APIHelper
from staxfattmerchantapi.apis.base_api import (
    BaseApi,
)
from staxfattmerchantapi.configuration import (
    Server,
)
from staxfattmerchantapi.http.http_method_enum import (
    HttpMethodEnum,
)


class TransactionApi(BaseApi):
    """A Controller to access Endpoints in the staxfattmerchantapi API."""

    def __init__(self, config):
        """Initialize TransactionApi object."""
        super(TransactionApi, self).__init__(config)

    def get_transactions(self,
                         page=None,
                         per_page=None,
                         keywords=None,
                         start_date=None,
                         end_date=None,
                         mtype=None,
                         success=None):
        """Perform a GET request to /transaction.

        Args:
            page (int, optional): Page number for pagination
            per_page (int, optional): Number of items per page
            keywords (str, optional): The request query parameter.
            start_date (date, optional): The request query parameter.
            end_date (date, optional): The request query parameter.
            mtype (str, optional): The request query parameter.
            success (bool, optional): The request query parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Paginated list of
                transactions

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction")
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                .key("page")
                .value(page))
            .query_param(Parameter()
                .key("per_page")
                .value(per_page))
            .query_param(Parameter()
                .key("keywords")
                .value(keywords))
            .query_param(Parameter()
                .key("startDate")
                .value(start_date))
            .query_param(Parameter()
                .key("endDate")
                .value(end_date))
            .query_param(Parameter()
                .key("type")
                .value(mtype))
            .query_param(Parameter()
                .key("success")
                .value(success))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .is_api_response(True),
        ).execute()

    def post_transaction(self,
                         body):
        """Perform a POST request to /transaction.

        Args:
            body (Any): The request body parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Transaction created

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction")
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body)
                .is_required(True))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .is_api_response(True),
        ).execute()

    def get_transaction(self,
                        id):
        """Perform a GET request to /transaction/{id}.

        Args:
            id (uuid|str): The request template parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Transaction details

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .is_api_response(True),
        ).execute()

    def put_transaction(self,
                        id,
                        body=None):
        """Perform a PUT request to /transaction/{id}.

        Args:
            id (uuid|str): The request template parameter.
            body (PutTransactionRequestBodyJson, optional): The request body
                parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Transaction updated

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def post_refund(self,
                    id,
                    body=None):
        """Perform a POST request to /transaction/{id}/refund.

        Args:
            id (uuid|str): The request template parameter.
            body (PostRefundRequestBodyJson, optional): The request body parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Refund created

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/refund")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .is_api_response(True),
        ).execute()

    def post_void(self,
                  id):
        """Perform a POST request to /transaction/{id}/void.

        Args:
            id (uuid|str): The request template parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Transaction voided

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/void")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .is_api_response(True),
        ).execute()

    def post_void_or_refund(self,
                            id,
                            body=None):
        """Perform a POST request to /transaction/{id}/void-or-refund.

        Args:
            id (uuid|str): The request template parameter.
            body (PostVoidOrRefundRequestBodyJson, optional): The request body
                parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Transaction voided or
                refunded

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/void-or-refund")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def post_capture(self,
                     id,
                     body=None):
        """Perform a POST request to /transaction/{id}/capture.

        Args:
            id (uuid|str): The request template parameter.
            body (PostCaptureRequestBodyJson, optional): The request body parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Transaction captured

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/capture")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def get_related_transaction(self,
                                id):
        """Perform a GET request to /transaction/{id}/related.

        Args:
            id (uuid|str): The request template parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Related transactions

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/related")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def put_receipt(self,
                    id,
                    method,
                    body=None):
        """Perform a PUT request to /transaction/{id}/receipt/{method}.

        Args:
            id (uuid|str): The request template parameter.
            method (PutReceiptMethod): The request template parameter.
            body (PutReceiptRequestBodyJson, optional): The request body parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Receipt sent

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/receipt/{method}")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .template_param(Parameter()
                .key("method")
                .value(method)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def post_receipt(self,
                     id,
                     method,
                     body=None):
        """Perform a POST request to /transaction/{id}/receipt/{method}.

        Args:
            id (uuid|str): The request template parameter.
            method (PostReceiptMethod): The request template parameter.
            body (Any, optional): The request body parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Receipt sent

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/receipt/{method}")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .template_param(Parameter()
                .key("method")
                .value(method)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def put_email_receipt(self,
                          id,
                          body=None):
        """Perform a PUT request to /transaction/{id}/receipt-email.

        Args:
            id (uuid|str): The request template parameter.
            body (PutEmailReceiptRequestBodyJson, optional): The request body
                parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Email receipt sent

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/receipt-email")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def post_email_receipt(self,
                           id,
                           body=None):
        """Perform a POST request to /transaction/{id}/receipt-email.

        Args:
            id (uuid|str): The request template parameter.
            body (PostEmailReceiptRequestBodyJson, optional): The request body
                parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Email receipt sent

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/receipt-email")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def put_sms_receipt(self,
                        id,
                        body=None):
        """Perform a PUT request to /transaction/{id}/receipt-sms.

        Args:
            id (uuid|str): The request template parameter.
            body (PutSmsReceiptRequestBodyJson, optional): The request body parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. SMS receipt sent

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/receipt-sms")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def post_sms_receipt(self,
                         id,
                         body=None):
        """Perform a POST request to /transaction/{id}/receipt-sms.

        Args:
            id (uuid|str): The request template parameter.
            body (PostSmsReceiptRequestBodyJson, optional): The request body
                parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. SMS receipt sent

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/receipt-sms")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def put_receipt_bulk_method(self,
                                method,
                                body=None):
        """Perform a PUT request to /transaction/receipt/{method}/bulk.

        Args:
            method (PutReceiptBulkMethodMethod): The request template parameter.
            body (PutReceiptBulkMethodRequestBodyJson, optional): The request body
                parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Receipts sent in bulk

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/receipt/{method}/bulk")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("method")
                .value(method)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def put_receipt_bulk(self,
                         body=None):
        """Perform a PUT request to /transaction/receipt/bulk.

        Args:
            body (PutReceiptBulkRequestBodyJson, optional): The request body
                parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Receipts sent in bulk

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/receipt/bulk")
            .http_method(HttpMethodEnum.PUT)
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def post_transaction_log(self,
                             body=None):
        """Perform a POST request to /transaction/log.

        Args:
            body (Any, optional): The request body parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Log created

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/log")
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()

    def get_transaction_funding(self,
                                id):
        """Perform a GET request to /transaction/{id}/funding.

        Args:
            id (uuid|str): The request template parameter.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Funding details

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/transaction/{id}/funding")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .auth(Single("bearerAuth")),
        ).response(
            ResponseHandler()
            .is_api_response(True),
        ).execute()
