from __future__ import annotations

from uuid import UUID

from .base import SubclientBase
from ..schemas import EventResponse


class EventsClient(SubclientBase):
    async def query_item_events(self, item_id: UUID) -> list[EventResponse]:
        response = await self._client.get(self._client.path(f"/events/items/{item_id}"))
        return self._client.parse_list(response, EventResponse)

    async def query_item_last_event(self, item_id: UUID) -> EventResponse:
        response = await self._client.get(
            self._client.path(f"/events/items/{item_id}/last")
        )
        return self._client.parse(response, EventResponse)

    async def query_item_last_n_events(
        self, item_id: UUID, n: int
    ) -> list[EventResponse]:
        response = await self._client.get(
            self._client.path(f"/events/items/{item_id}/last/{n}")
        )
        return self._client.parse_list(response, EventResponse)
