# coding: utf-8

"""
Waybiller External API - with fixes

The **Waybiller External API** is a feature that allows companies to access **Waybiller** data as JSON objects and create **Waybiller** instances out of their own data.  To make integration easier for the companies, the external API provides mapping support - it is possible to create company-specific mappings for object identifiers (such as destination and origin).  These mappings will be used for representing companies data from external API, and for converting the values during the creation of **Waybiller** instances (such as transport orders and waybills).  Most of the API responses contain mapped values, which may be null if the company doesn't have a mapping for this object.  Unique **Waybiller** identifiers and values can be accessed via the `raw_data` key.  The API is HTTPS and JSON based.  ### Pagination  By default, list endpoint responses are presented in pages of 30 items.  It is possible to control the page size using the `limit` parameter: `/external-api/<some-list-endpoint>/?limit=<number>`, where `<number>` is an integer between 1 and 1000.

The version of the OpenAPI document: v1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""  # noqa: E501

import warnings
from typing import Any, Dict, List, Optional, Tuple, Union

from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call
from typing_extensions import Annotated

from pywaybiller.openapi_client.api_client import ApiClient, RequestSerialized
from pywaybiller.openapi_client.api_response import ApiResponse
from pywaybiller.openapi_client.models.paginated_external_api_loader_action_log_list import (
    PaginatedExternalAPILoaderActionLogList,
)
from pywaybiller.openapi_client.rest import RESTResponseType


class LoaderActionLogsApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client

    @validate_call
    def loader_action_logs_list(
        self,
        limit: Annotated[
            Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]],
            Field(description="Maximum number of objects to return per page"),
        ] = None,
        loader_unit_id: Annotated[
            Optional[StrictInt],
            Field(
                description="Filters loader action logs for your company with the specified loader unit ID"
            ),
        ] = None,
        offset: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=0)]],
            Field(description="The initial index from which to return the results"),
        ] = None,
        timestamp: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (exact)"
            ),
        ] = None,
        timestamp__gt: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (greater than)"
            ),
        ] = None,
        timestamp__gte: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (greater than or equal)"
            ),
        ] = None,
        timestamp__isnull: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company that do not have a timestamp"
            ),
        ] = None,
        timestamp__lt: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (less than)"
            ),
        ] = None,
        timestamp__lte: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (less than or equal)"
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> PaginatedExternalAPILoaderActionLogList:
        """Querying loader action logs

        Returns all loader action logs created by your company according to the specified filters.

        :param limit: Maximum number of objects to return per page
        :type limit: int
        :param loader_unit_id: Filters loader action logs for your company with the specified loader unit ID
        :type loader_unit_id: int
        :param offset: The initial index from which to return the results
        :type offset: int
        :param timestamp: Filters loader action logs for your company within the specified time period (exact)
        :type timestamp: str
        :param timestamp__gt: Filters loader action logs for your company within the specified time period (greater than)
        :type timestamp__gt: str
        :param timestamp__gte: Filters loader action logs for your company within the specified time period (greater than or equal)
        :type timestamp__gte: str
        :param timestamp__isnull: Filters loader action logs for your company that do not have a timestamp
        :type timestamp__isnull: str
        :param timestamp__lt: Filters loader action logs for your company within the specified time period (less than)
        :type timestamp__lt: str
        :param timestamp__lte: Filters loader action logs for your company within the specified time period (less than or equal)
        :type timestamp__lte: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._loader_action_logs_list_serialize(
            limit=limit,
            loader_unit_id=loader_unit_id,
            offset=offset,
            timestamp=timestamp,
            timestamp__gt=timestamp__gt,
            timestamp__gte=timestamp__gte,
            timestamp__isnull=timestamp__isnull,
            timestamp__lt=timestamp__lt,
            timestamp__lte=timestamp__lte,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedExternalAPILoaderActionLogList",
            "403": "DestinationsList403Response",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data

    @validate_call
    def loader_action_logs_list_with_http_info(
        self,
        limit: Annotated[
            Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]],
            Field(description="Maximum number of objects to return per page"),
        ] = None,
        loader_unit_id: Annotated[
            Optional[StrictInt],
            Field(
                description="Filters loader action logs for your company with the specified loader unit ID"
            ),
        ] = None,
        offset: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=0)]],
            Field(description="The initial index from which to return the results"),
        ] = None,
        timestamp: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (exact)"
            ),
        ] = None,
        timestamp__gt: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (greater than)"
            ),
        ] = None,
        timestamp__gte: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (greater than or equal)"
            ),
        ] = None,
        timestamp__isnull: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company that do not have a timestamp"
            ),
        ] = None,
        timestamp__lt: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (less than)"
            ),
        ] = None,
        timestamp__lte: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (less than or equal)"
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[PaginatedExternalAPILoaderActionLogList]:
        """Querying loader action logs

        Returns all loader action logs created by your company according to the specified filters.

        :param limit: Maximum number of objects to return per page
        :type limit: int
        :param loader_unit_id: Filters loader action logs for your company with the specified loader unit ID
        :type loader_unit_id: int
        :param offset: The initial index from which to return the results
        :type offset: int
        :param timestamp: Filters loader action logs for your company within the specified time period (exact)
        :type timestamp: str
        :param timestamp__gt: Filters loader action logs for your company within the specified time period (greater than)
        :type timestamp__gt: str
        :param timestamp__gte: Filters loader action logs for your company within the specified time period (greater than or equal)
        :type timestamp__gte: str
        :param timestamp__isnull: Filters loader action logs for your company that do not have a timestamp
        :type timestamp__isnull: str
        :param timestamp__lt: Filters loader action logs for your company within the specified time period (less than)
        :type timestamp__lt: str
        :param timestamp__lte: Filters loader action logs for your company within the specified time period (less than or equal)
        :type timestamp__lte: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._loader_action_logs_list_serialize(
            limit=limit,
            loader_unit_id=loader_unit_id,
            offset=offset,
            timestamp=timestamp,
            timestamp__gt=timestamp__gt,
            timestamp__gte=timestamp__gte,
            timestamp__isnull=timestamp__isnull,
            timestamp__lt=timestamp__lt,
            timestamp__lte=timestamp__lte,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedExternalAPILoaderActionLogList",
            "403": "DestinationsList403Response",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )

    @validate_call
    def loader_action_logs_list_without_preload_content(
        self,
        limit: Annotated[
            Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]],
            Field(description="Maximum number of objects to return per page"),
        ] = None,
        loader_unit_id: Annotated[
            Optional[StrictInt],
            Field(
                description="Filters loader action logs for your company with the specified loader unit ID"
            ),
        ] = None,
        offset: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=0)]],
            Field(description="The initial index from which to return the results"),
        ] = None,
        timestamp: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (exact)"
            ),
        ] = None,
        timestamp__gt: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (greater than)"
            ),
        ] = None,
        timestamp__gte: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (greater than or equal)"
            ),
        ] = None,
        timestamp__isnull: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company that do not have a timestamp"
            ),
        ] = None,
        timestamp__lt: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (less than)"
            ),
        ] = None,
        timestamp__lte: Annotated[
            Optional[StrictStr],
            Field(
                description="Filters loader action logs for your company within the specified time period (less than or equal)"
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Querying loader action logs

        Returns all loader action logs created by your company according to the specified filters.

        :param limit: Maximum number of objects to return per page
        :type limit: int
        :param loader_unit_id: Filters loader action logs for your company with the specified loader unit ID
        :type loader_unit_id: int
        :param offset: The initial index from which to return the results
        :type offset: int
        :param timestamp: Filters loader action logs for your company within the specified time period (exact)
        :type timestamp: str
        :param timestamp__gt: Filters loader action logs for your company within the specified time period (greater than)
        :type timestamp__gt: str
        :param timestamp__gte: Filters loader action logs for your company within the specified time period (greater than or equal)
        :type timestamp__gte: str
        :param timestamp__isnull: Filters loader action logs for your company that do not have a timestamp
        :type timestamp__isnull: str
        :param timestamp__lt: Filters loader action logs for your company within the specified time period (less than)
        :type timestamp__lt: str
        :param timestamp__lte: Filters loader action logs for your company within the specified time period (less than or equal)
        :type timestamp__lte: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._loader_action_logs_list_serialize(
            limit=limit,
            loader_unit_id=loader_unit_id,
            offset=offset,
            timestamp=timestamp,
            timestamp__gt=timestamp__gt,
            timestamp__gte=timestamp__gte,
            timestamp__isnull=timestamp__isnull,
            timestamp__lt=timestamp__lt,
            timestamp__lte=timestamp__lte,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedExternalAPILoaderActionLogList",
            "403": "DestinationsList403Response",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data.response

    def _loader_action_logs_list_serialize(
        self,
        limit,
        loader_unit_id,
        offset,
        timestamp,
        timestamp__gt,
        timestamp__gte,
        timestamp__isnull,
        timestamp__lt,
        timestamp__lte,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: Dict[str, str] = {}

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if limit is not None:
            _query_params.append(("limit", limit))

        if loader_unit_id is not None:
            _query_params.append(("loader_unit_id", loader_unit_id))

        if offset is not None:
            _query_params.append(("offset", offset))

        if timestamp is not None:
            _query_params.append(("timestamp", timestamp))

        if timestamp__gt is not None:
            _query_params.append(("timestamp__gt", timestamp__gt))

        if timestamp__gte is not None:
            _query_params.append(("timestamp__gte", timestamp__gte))

        if timestamp__isnull is not None:
            _query_params.append(("timestamp__isnull", timestamp__isnull))

        if timestamp__lt is not None:
            _query_params.append(("timestamp__lt", timestamp__lt))

        if timestamp__lte is not None:
            _query_params.append(("timestamp__lte", timestamp__lte))

        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _header_params["Accept"] = self.api_client.select_header_accept(
                ["application/json"]
            )

        # authentication setting
        _auth_settings: List[str] = ["ApiKeyAuth"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/external-api/loader-action-logs/",
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth,
        )
