"""visaacceptancemergedspec.

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

# ruff: noqa: D410, E501, E101, D206
from apimatic_core.authentication.multiple.and_auth_group import (
    And,
)
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 visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.apis.base_api import (
    BaseApi,
)
from visaacceptancemergedspec.configuration import (
    Server,
)
from visaacceptancemergedspec.exceptions.api_exception import (
    ApiException,
)
from visaacceptancemergedspec.exceptions.pts_v_1_transaction_batches_get_400_response_1_exception import (  # noqa: E501
    PtsV1TransactionBatchesGet400Response1Exception,
)
from visaacceptancemergedspec.exceptions.pts_v_1_transaction_batches_get_401_response_1_exception import (  # noqa: E501
    PtsV1TransactionBatchesGet401Response1Exception,
)
from visaacceptancemergedspec.exceptions.pts_v_1_transaction_batches_get_403_response_1_exception import (  # noqa: E501
    PtsV1TransactionBatchesGet403Response1Exception,
)
from visaacceptancemergedspec.exceptions.pts_v_1_transaction_batches_get_404_response_1_exception import (  # noqa: E501
    PtsV1TransactionBatchesGet404Response1Exception,
)
from visaacceptancemergedspec.exceptions.pts_v_1_transaction_batches_get_500_response_1_exception import (  # noqa: E501
    PtsV1TransactionBatchesGet500Response1Exception,
)
from visaacceptancemergedspec.exceptions.pts_v_1_transaction_batches_get_502_response_1_exception import (  # noqa: E501
    PtsV1TransactionBatchesGet502Response1Exception,
)
from visaacceptancemergedspec.http.http_method_enum import (
    HttpMethodEnum,
)
from visaacceptancemergedspec.models.pts_v_1_transaction_batches_get_200_response import (  # noqa: E501
    PtsV1TransactionBatchesGet200Response,
)
from visaacceptancemergedspec.models.pts_v_1_transaction_batches_id_get_200_response import (  # noqa: E501
    PtsV1TransactionBatchesIdGet200Response,
)


class TransactionBatchesApi(BaseApi):
    """A Controller to access Endpoints in the visaacceptancemergedspec API."""

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

    def get_transaction_batches(self,
                                start_time,
                                end_time):
        """Perform a GET request to /pts/v1/transaction-batches.

        Provide the date and time search range to get a list of Batch Files ready for
        settlement

        Args:
            start_time (datetime): Valid report Start Time in **ISO 8601 format**
                Please refer the following link to know more about ISO 8601
                format.[Rfc Date Format](   **Example date format:**   -
                yyyy-MM-dd'T'HH:mm:ss.SSSZZ
            end_time (datetime): Valid report End Time in **ISO 8601 format** Please
                refer the following link to know more about ISO 8601 format.[Rfc Date
                Format](   **Example date format:**   - yyyy-MM-dd'T'HH:mm:ss.SSSZZ

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

        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("/pts/v1/transaction-batches")
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                .key("startTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    start_time))
                .is_required(True))
            .query_param(Parameter()
                .key("endTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    end_time))
                .is_required(True))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PtsV1TransactionBatchesGet200Response.from_dictionary)
            .is_api_response(True)
            .local_error("400",
                "Bad Request",
                PtsV1TransactionBatchesGet400Response1Exception)
            .local_error("401",
                "Not Authorized",
                PtsV1TransactionBatchesGet401Response1Exception)
            .local_error("403",
                "No Authenticated",
                PtsV1TransactionBatchesGet403Response1Exception)
            .local_error("404",
                "No Reports Found",
                PtsV1TransactionBatchesGet404Response1Exception)
            .local_error("500",
                "Bad Gateway",
                PtsV1TransactionBatchesGet500Response1Exception),
        ).execute()

    def get_transaction_batch_id(self,
                                 id):
        """Perform a GET request to /pts/v1/transaction-batches/{id}.

        This API provides details like upload date, completion date, transaction
        count and accepted and rejected transaction count of the individual batch
        file using the batch id

        Args:
            id (str): The batch id assigned for the template.

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

        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("/pts/v1/transaction-batches/{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(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PtsV1TransactionBatchesIdGet200Response.from_dictionary)
            .is_api_response(True)
            .local_error("400",
                "Bad Request",
                PtsV1TransactionBatchesGet400Response1Exception)
            .local_error("401",
                "Not Authorized",
                PtsV1TransactionBatchesGet401Response1Exception)
            .local_error("403",
                "No Authenticated",
                PtsV1TransactionBatchesGet403Response1Exception)
            .local_error("404",
                "No Reports Found",
                PtsV1TransactionBatchesGet404Response1Exception)
            .local_error("502",
                "Bad Gateway",
                PtsV1TransactionBatchesGet502Response1Exception),
        ).execute()

    def get_transaction_batch_details(self,
                                      id,
                                      upload_date=None,
                                      status=None):
        """Perform a GET request to /pts/v1/transaction-batch-details/{id}.

        Provides real-time detailed status information about the transactions that
        you previously uploaded in the Business Center or processed with the Offline
        Transaction File Submission service.

        Args:
            id (str): The batch id assigned for the template.
            upload_date (date, optional): Date in which the original batch file was
                uploaded. Date must be in ISO-8601 format. Please refer the following
                link to know more about ISO 8601 format.[Rfc Date Format]( **Example
                date format:**  - yyyy-MM-dd
            status (str, optional): Allows you to filter by rejected response.  Valid
                values: - Rejected

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

        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("/pts/v1/transaction-batch-details/{id}")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("id")
                .value(id)
                .is_required(True)
                .should_encode(True))
            .query_param(Parameter()
                .key("uploadDate")
                .value(upload_date))
            .query_param(Parameter()
                .key("status")
                .value(status))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .is_api_response(True)
            .local_error("400", "Bad Request", ApiException)
            .local_error("401", "Not Authorized", ApiException)
            .local_error("403", "No Authenticated", ApiException)
            .local_error("404", "No Reports Found", ApiException)
            .local_error("502", "Bad Gateway", ApiException),
        ).execute()
