# -*- coding: utf-8 -*-

"""
shelldatareportingapis

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

from shelldatareportingapis.api_helper import APIHelper
from shelldatareportingapis.configuration import Server
from shelldatareportingapis.controllers.base_controller import BaseController
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter
from shelldatareportingapis.http.http_method_enum import HttpMethodEnum
from apimatic_core.authentication.multiple.single_auth import Single
from apimatic_core.configurations.endpoint_configuration import EndpointConfiguration
from shelldatareportingapis.models.invoice_search_response import InvoiceSearchResponse
from shelldatareportingapis.models.invoice_summary_response import InvoiceSummaryResponse
from shelldatareportingapis.models.statement_of_account_response import StatementOfAccountResponse
from shelldatareportingapis.models.invoice_dates_response_data import InvoiceDatesResponseData
from shelldatareportingapis.models.search_statement_of_account_response import SearchStatementOfAccountResponse
from shelldatareportingapis.models.search_documents_response import SearchDocumentsResponse
from shelldatareportingapis.models.eid_document_response import EIDDocumentResponse
from shelldatareportingapis.exceptions.error_object_exception import ErrorObjectException


class InvoiceController(BaseController):

    """A Controller to access Endpoints in the shelldatareportingapis API."""
    def __init__(self, config):
        super(InvoiceController, self).__init__(config)

    def invoice_search(self,
                       request_id,
                       body=None):
        """Does a POST request to /invoice-management/v1/search.

        This API allows to search invoice data in the Shell Card Platform. It
        provides flexible search criteria in the request body and supports
        paging. 
        This API will also query the relevant invoice documents list and
        return a reference number that can be used to download invoice
        documents (PDF and Proofing elements in a zip file).
        #### Supported operations
          * Search invoices by account
          * Search invoices by invoice type or invoice status
          * Search invoices by invoice id or number
          * Search invoices by invoiced country
          * Search invoices including einvoices
          * Search invoices by summary document
          * Search invoices by statement of account
          * Search invoices by fixed and custom date periods

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (InvoiceSearchRequest, optional): Invoice Search RequestBody

        Returns:
            InvoiceSearchResponse: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/search')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .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('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(InvoiceSearchResponse.from_dictionary)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).execute()

    def invoice_summary(self,
                        request_id,
                        body=None):
        """Does a POST request to /invoice-management/v1/summary.

        This API returns the high level summary of invoices that match the 
        given search criteria. The same search criteria as the endpoint
        `/v1/invoice/search` is supported with the exception of paging related
        parameters. 
        #### Supported operations
          * Search invoices by account
          * Search invoices by invoice type or invoice status
          * Search invoices by invoice id or number
          * Search invoices by invoiced country
          * Search invoices including einvoices
          * Search invoices by summary document
          * Search invoices by statement of account
          * Search invoices by fixed and custom date periods

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (InvoiceSummaryRequest, optional): Invoice Search RequestBody

        Returns:
            InvoiceSummaryResponse: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/summary')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .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('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(InvoiceSummaryResponse.from_dictionary)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).execute()

    def statement_of_account(self,
                             request_id,
                             body=None):
        """Does a POST request to /invoice-management/v1/statementofaccount.

        This API allows querying the details of the latest statement of
        account (SOA) generated for a given Payer. 
        The endpoint supports querying SOA documents by various input
        parameters specified in the request body.
        #### Supported operations
          * Search invoice SOA by payer and account
          * Search invoice SOA including monthly trend (last 13 months invocie
        trend summary)
          * Search invoice SOA including past SOAs
          * Search invoice SOA including due/overdue documents
          * Search invoice SOA including invoice summary

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (StatementOfAccountRequest, optional): StatementOfAccount
                RequestBody

        Returns:
            StatementOfAccountResponse: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/statementofaccount')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .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('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(StatementOfAccountResponse.from_dictionary)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).execute()

    def dates(self,
              request_id,
              body=None):
        """Does a POST request to /invoice-management/v1/dates.

        - This API will return the list of Invoice Dates and Numbers for the
        given date range. If the dates are not provided then it will fetch the
        data for past 13 months.

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (InvoiceDatesRequest, optional): StatementOfAccount
                RequestBody

        Returns:
            InvoiceDatesResponseData: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/dates')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .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('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(InvoiceDatesResponseData.from_dictionary)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).execute()

    def search_statement_of_account(self,
                                    request_id,
                                    body=None):
        """Does a POST request to /invoice-management/v1/searchstatementofaccount.

        - This API will allow querying of SOA from different systems

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (SearchStatementOfAccountRequest, optional):
                searchstatementofaccount RequestBody

        Returns:
            SearchStatementOfAccountResponse: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/searchstatementofaccount')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .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('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(SearchStatementOfAccountResponse.from_dictionary)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).execute()

    def search_documents(self,
                         request_id,
                         body=None):
        """Does a POST request to /invoice-management/v1/searchdocuments.

        - This API allows querying the details of all invoices successfully
        uploaded to the Worldline invoice repository and file reference
        numbers for downloading.

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (SearchDocumentsRequest, optional): SearchDocuments
                RequestBody

        Returns:
            SearchDocumentsResponse: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/searchdocuments')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .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('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(SearchDocumentsResponse.from_dictionary)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).execute()

    def eid_search(self,
                   request_id,
                   body=None):
        """Does a POST request to /invoice-management/v1/eidsearch.

        - This API provides the functionality needed for the screen “EID
        FILES” in the web interface. It allows retrieving a list of EIDs based
        on search criteria.

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (EIDSearchRequest, optional): EIDSearch RequestBody

        Returns:
            EIDDocumentResponse: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/eidsearch')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .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('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(EIDDocumentResponse.from_dictionary)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).execute()

    def download(self,
                 request_id,
                 body=None):
        """Does a POST request to /invoice-management/v1/download.

        - This API downloads Invoice Documents i.e., ZIP file with Invoice PDF
        file and Proofing Elements in XML format from invoice repository.

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (InvoiceDownloadRequest, optional): Invoice Download
                RequestBody

        Returns:
            binary: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/download')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .header_param(Parameter()
                          .key('Content-Type')
                          .value('application/json'))
            .body_param(Parameter()
                        .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).endpoint_configuration(
            EndpointConfiguration()
            .has_binary_response(True)
        ).execute()

    def eid_download(self,
                     request_id,
                     body=None):
        """Does a POST request to /invoice-management/v1/eiddownload.

        - This service allows downloading one or more EID documents and the
        corresponding signature material (where applicable) in one single
        request 
        - The number of EID that can be downloaded at once is limited to 100
        documents.

        Args:
            request_id (str): Mandatory UUID (according to RFC 4122 standards)
                for requests and responses. This will be played back in the
                response from the request.
            body (EIDDownloadRequest, optional): EIDInvoice Download
                RequestBody

        Returns:
            binary: Response from the API. 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.SHELL)
            .path('/invoice-management/v1/eiddownload')
            .http_method(HttpMethodEnum.POST)
            .header_param(Parameter()
                          .key('RequestId')
                          .value(request_id))
            .header_param(Parameter()
                          .key('Content-Type')
                          .value('application/json'))
            .body_param(Parameter()
                        .value(body))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single('BearerToken'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .local_error('400', 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).', ErrorObjectException)
            .local_error('401', 'The request has not been applied because it lacks valid  authentication credentials for the target resource.', ErrorObjectException)
            .local_error('403', 'Forbidden', ErrorObjectException)
            .local_error('404', 'The origin server did not find a current representation  for the target resource or is not willing to disclose  that one exists.', ErrorObjectException)
            .local_error('500', 'The server encountered an unexpected condition that  prevented it from fulfilling the request.', ErrorObjectException)
        ).endpoint_configuration(
            EndpointConfiguration()
            .has_binary_response(True)
        ).execute()
