# This file was auto-generated by Fern from our API Definition.

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..errors.bad_request_error import BadRequestError
from ..errors.internal_server_error import InternalServerError
from ..errors.service_unavailable_error import ServiceUnavailableError
from ..errors.unauthorized_error import UnauthorizedError
from ..types.payabli_api_response import PayabliApiResponse
from .types.stat_basic_query_record import StatBasicQueryRecord
from .types.statistics_vendor_query_record import StatisticsVendorQueryRecord
from .types.subscription_stats_query_record import SubscriptionStatsQueryRecord


class RawStatisticClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def basic_stats(
        self,
        entry_id: int,
        freq: str,
        level: int,
        mode: str,
        *,
        end_date: typing.Optional[str] = None,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        start_date: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[typing.List[StatBasicQueryRecord]]:
        """
        Retrieves the basic statistics for an organization or a paypoint, for a given time period, grouped by a particular frequency.

        Parameters
        ----------
        entry_id : int
            Identifier in Payabli for the entity.

        freq : str
            Frequency to group series. Allowed values:

            - `m` - monthly
            - `w` - weekly
            - `d` - daily
            - `h` - hourly

            For example, `w` groups the results by week.

        level : int
            The entry level for the request:
              - 0 for Organization
              - 2 for Paypoint

        mode : str
            Mode for the request. Allowed values:

            - `custom` - Allows you to set a custom date range
            - `ytd` - Year To Date
            - `mtd` - Month To Date
            - `wtd` - Week To Date
            - `today` - All current day
            - `m12` - Last 12 months
            - `d30` - Last 30 days
            - `h24` - Last 24 hours
            - `lasty` - Last Year
            - `lastm` - Last Month
            - `lastw` - Last Week
            - `yesterday` - Last Day


        end_date : typing.Optional[str]
            Used with `custom` mode. The end date for the range.
            Valid formats:
              - YYYY-mm-dd
              - YYYY/mm/dd
              - mm-dd-YYYY
              - mm/dd/YYYY

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters.

        start_date : typing.Optional[str]
            Used with `custom` mode. The start date for the range.
            Valid formats:
               - YYYY-mm-dd
               - YYYY/mm/dd
               -  mm-dd-YYYY
               - mm/dd/YYYY

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[typing.List[StatBasicQueryRecord]]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Statistic/basic/{jsonable_encoder(mode)}/{jsonable_encoder(freq)}/{jsonable_encoder(level)}/{jsonable_encoder(entry_id)}",
            method="GET",
            params={
                "endDate": end_date,
                "parameters": parameters,
                "startDate": start_date,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[StatBasicQueryRecord],
                    parse_obj_as(
                        type_=typing.List[StatBasicQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def customer_basic_stats(
        self,
        customer_id: int,
        freq: str,
        mode: str,
        *,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[typing.List[SubscriptionStatsQueryRecord]]:
        """
        Retrieves the basic statistics for a customer for a specific time period, grouped by a selected frequency.

        Parameters
        ----------
        customer_id : int
            Payabli-generated customer ID. Maps to "Customer ID" column in PartnerHub.

        freq : str
            Frequency to group series. Allowed values:

            - `m` - monthly
            - `w` - weekly
            - `d` - daily
            - `h` - hourly

            For example, `w` groups the results by week.

        mode : str
            Mode for request. Allowed values:

            - `ytd` - Year To Date
            - `mtd` - Month To Date
            - `wtd` - Week To Date
            - `today` - All current day
            - `m12` - Last 12 months
            - `d30` - Last 30 days
            - `h24` - Last 24 hours
            - `lasty` - Last Year
            - `lastm` - Last Month
            - `lastw` - Last Week
            - `yesterday` - Last Day

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[typing.List[SubscriptionStatsQueryRecord]]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Statistic/customerbasic/{jsonable_encoder(mode)}/{jsonable_encoder(freq)}/{jsonable_encoder(customer_id)}",
            method="GET",
            params={
                "parameters": parameters,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[SubscriptionStatsQueryRecord],
                    parse_obj_as(
                        type_=typing.List[SubscriptionStatsQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def sub_stats(
        self,
        entry_id: int,
        interval: str,
        level: int,
        *,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[typing.List[StatBasicQueryRecord]]:
        """
        Retrieves the subscription statistics for a given interval for a paypoint or organization.

        Parameters
        ----------
        entry_id : int
            Identifier in Payabli for the entity.

        interval : str
            Interval to get the data. Allowed values:

            - `all` - all intervals
            - `30` - 1-30 days
            - `60` - 31-60 days
            - `90` - 61-90 days
            - `plus` - +90 days

        level : int
            The entry level for the request:
              - 0 for Organization
              - 2 for Paypoint

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[typing.List[StatBasicQueryRecord]]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Statistic/subscriptions/{jsonable_encoder(interval)}/{jsonable_encoder(level)}/{jsonable_encoder(entry_id)}",
            method="GET",
            params={
                "parameters": parameters,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[StatBasicQueryRecord],
                    parse_obj_as(
                        type_=typing.List[StatBasicQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def vendor_basic_stats(
        self,
        freq: str,
        id_vendor: int,
        mode: str,
        *,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[typing.List[StatisticsVendorQueryRecord]]:
        """
        Retrieve the basic statistics about a vendor for a given time period, grouped by frequency.

        Parameters
        ----------
        freq : str
            Frequency to group series. Allowed values:

            - `m` - monthly
            - `w` - weekly
            - `d` - daily
            - `h` - hourly

            For example, `w` groups the results by week.

        id_vendor : int
            Vendor ID.

        mode : str
            Mode for request. Allowed values:

            - `ytd` - Year To Date
            - `mtd` - Month To Date
            - `wtd` - Week To Date
            - `today` - All current day
            - `m12` - Last 12 months
            - `d30` - Last 30 days
            - `h24` - Last 24 hours
            - `lasty` - Last Year
            - `lastm` - Last Month
            - `lastw` - Last Week
            - `yesterday` - Last Day

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[typing.List[StatisticsVendorQueryRecord]]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Statistic/vendorbasic/{jsonable_encoder(mode)}/{jsonable_encoder(freq)}/{jsonable_encoder(id_vendor)}",
            method="GET",
            params={
                "parameters": parameters,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[StatisticsVendorQueryRecord],
                    parse_obj_as(
                        type_=typing.List[StatisticsVendorQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawStatisticClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def basic_stats(
        self,
        entry_id: int,
        freq: str,
        level: int,
        mode: str,
        *,
        end_date: typing.Optional[str] = None,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        start_date: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[typing.List[StatBasicQueryRecord]]:
        """
        Retrieves the basic statistics for an organization or a paypoint, for a given time period, grouped by a particular frequency.

        Parameters
        ----------
        entry_id : int
            Identifier in Payabli for the entity.

        freq : str
            Frequency to group series. Allowed values:

            - `m` - monthly
            - `w` - weekly
            - `d` - daily
            - `h` - hourly

            For example, `w` groups the results by week.

        level : int
            The entry level for the request:
              - 0 for Organization
              - 2 for Paypoint

        mode : str
            Mode for the request. Allowed values:

            - `custom` - Allows you to set a custom date range
            - `ytd` - Year To Date
            - `mtd` - Month To Date
            - `wtd` - Week To Date
            - `today` - All current day
            - `m12` - Last 12 months
            - `d30` - Last 30 days
            - `h24` - Last 24 hours
            - `lasty` - Last Year
            - `lastm` - Last Month
            - `lastw` - Last Week
            - `yesterday` - Last Day


        end_date : typing.Optional[str]
            Used with `custom` mode. The end date for the range.
            Valid formats:
              - YYYY-mm-dd
              - YYYY/mm/dd
              - mm-dd-YYYY
              - mm/dd/YYYY

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters.

        start_date : typing.Optional[str]
            Used with `custom` mode. The start date for the range.
            Valid formats:
               - YYYY-mm-dd
               - YYYY/mm/dd
               -  mm-dd-YYYY
               - mm/dd/YYYY

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[typing.List[StatBasicQueryRecord]]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Statistic/basic/{jsonable_encoder(mode)}/{jsonable_encoder(freq)}/{jsonable_encoder(level)}/{jsonable_encoder(entry_id)}",
            method="GET",
            params={
                "endDate": end_date,
                "parameters": parameters,
                "startDate": start_date,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[StatBasicQueryRecord],
                    parse_obj_as(
                        type_=typing.List[StatBasicQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def customer_basic_stats(
        self,
        customer_id: int,
        freq: str,
        mode: str,
        *,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[typing.List[SubscriptionStatsQueryRecord]]:
        """
        Retrieves the basic statistics for a customer for a specific time period, grouped by a selected frequency.

        Parameters
        ----------
        customer_id : int
            Payabli-generated customer ID. Maps to "Customer ID" column in PartnerHub.

        freq : str
            Frequency to group series. Allowed values:

            - `m` - monthly
            - `w` - weekly
            - `d` - daily
            - `h` - hourly

            For example, `w` groups the results by week.

        mode : str
            Mode for request. Allowed values:

            - `ytd` - Year To Date
            - `mtd` - Month To Date
            - `wtd` - Week To Date
            - `today` - All current day
            - `m12` - Last 12 months
            - `d30` - Last 30 days
            - `h24` - Last 24 hours
            - `lasty` - Last Year
            - `lastm` - Last Month
            - `lastw` - Last Week
            - `yesterday` - Last Day

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[typing.List[SubscriptionStatsQueryRecord]]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Statistic/customerbasic/{jsonable_encoder(mode)}/{jsonable_encoder(freq)}/{jsonable_encoder(customer_id)}",
            method="GET",
            params={
                "parameters": parameters,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[SubscriptionStatsQueryRecord],
                    parse_obj_as(
                        type_=typing.List[SubscriptionStatsQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def sub_stats(
        self,
        entry_id: int,
        interval: str,
        level: int,
        *,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[typing.List[StatBasicQueryRecord]]:
        """
        Retrieves the subscription statistics for a given interval for a paypoint or organization.

        Parameters
        ----------
        entry_id : int
            Identifier in Payabli for the entity.

        interval : str
            Interval to get the data. Allowed values:

            - `all` - all intervals
            - `30` - 1-30 days
            - `60` - 31-60 days
            - `90` - 61-90 days
            - `plus` - +90 days

        level : int
            The entry level for the request:
              - 0 for Organization
              - 2 for Paypoint

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[typing.List[StatBasicQueryRecord]]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Statistic/subscriptions/{jsonable_encoder(interval)}/{jsonable_encoder(level)}/{jsonable_encoder(entry_id)}",
            method="GET",
            params={
                "parameters": parameters,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[StatBasicQueryRecord],
                    parse_obj_as(
                        type_=typing.List[StatBasicQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def vendor_basic_stats(
        self,
        freq: str,
        id_vendor: int,
        mode: str,
        *,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[typing.List[StatisticsVendorQueryRecord]]:
        """
        Retrieve the basic statistics about a vendor for a given time period, grouped by frequency.

        Parameters
        ----------
        freq : str
            Frequency to group series. Allowed values:

            - `m` - monthly
            - `w` - weekly
            - `d` - daily
            - `h` - hourly

            For example, `w` groups the results by week.

        id_vendor : int
            Vendor ID.

        mode : str
            Mode for request. Allowed values:

            - `ytd` - Year To Date
            - `mtd` - Month To Date
            - `wtd` - Week To Date
            - `today` - All current day
            - `m12` - Last 12 months
            - `d30` - Last 30 days
            - `h24` - Last 24 hours
            - `lasty` - Last Year
            - `lastm` - Last Month
            - `lastw` - Last Week
            - `yesterday` - Last Day

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            List of parameters

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[typing.List[StatisticsVendorQueryRecord]]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Statistic/vendorbasic/{jsonable_encoder(mode)}/{jsonable_encoder(freq)}/{jsonable_encoder(id_vendor)}",
            method="GET",
            params={
                "parameters": parameters,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[StatisticsVendorQueryRecord],
                    parse_obj_as(
                        type_=typing.List[StatisticsVendorQueryRecord],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
