"""EV Search API."""

from ..api import BaseApi
from .models import EvSearchByIdParams, EvSearchNearbyParams, SearchResponse


class EVSearchApi(BaseApi):
    """EV Search API.

    EV Search is a REST API limited to and optimized for electric vehicle station POI category. It provides complete EV POI data including static
    location information (lat/long), address, opening hours, access restrictions, technical specs of the charging station (connector type, voltage,
    power, current, current type), etc. as well as dynamic availability status. Wide range of EV specific filters (including dynamic availability)
    allows for narrowing the search results to match the personal preference (like charging power or access type) of the driver or the technical
    specification of the electric vehicle (connector type).

    For more information, see: https://developer.tomtom.com/ev-search-api/documentation/product-information/introduction
    """

    async def get_ev_search_nearby(
        self,
        *,
        params: EvSearchNearbyParams | None = None,
    ) -> SearchResponse:
        """Get EV search nearby.

        For more information, see: https://developer.tomtom.com/ev-search-api/documentation/ev-search-api/ev-search-nearby

        Args:
            params (EvSearchNearbyParams | None, optional): Additional parameters for the request. Defaults to None.

        Returns:
            SearchResponse: Response containing search results.
        """
        response = await self.get(
            endpoint="/search/2/evsearch",
            params=params,
        )

        return await response.deserialize(SearchResponse)

    async def get_ev_search_by_id(
        self,
        *,
        params: EvSearchByIdParams | None = None,
    ) -> SearchResponse:
        """Get EV search by id.

        For more information, see: https://developer.tomtom.com/ev-search-api/documentation/ev-search-api/ev-search-by-id

        Args:
            params (EvSearchByIdParams | None, optional): Additional parameters for the request. Defaults to None.

        Returns:
            SearchResponse: Response containing search results.
        """
        response = await self.get(
            endpoint="/search/2/evbyid",
            params=params,
        )

        return await response.deserialize(SearchResponse)
