"""
Queue resource.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
    from ..client.base import BaseClient


class QueueResource:
    """Resource for managing the posting queue."""

    _BASE_PATH = "/v1/queue"

    def __init__(self, client: "BaseClient") -> None:
        self._client = client

    def get_slots(self, *, profile_id: str | None = None) -> dict[str, Any]:
        """Get queue slots."""
        params = {"profileId": profile_id} if profile_id else None
        return self._client._get(f"{self._BASE_PATH}/slots", params=params)

    def preview(self, *, profile_id: str | None = None) -> dict[str, Any]:
        """Preview next queue slot."""
        params = {"profileId": profile_id} if profile_id else None
        return self._client._get(f"{self._BASE_PATH}/preview", params=params)

    def next_slot(self, *, profile_id: str | None = None) -> dict[str, Any]:
        """Get next available slot."""
        params = {"profileId": profile_id} if profile_id else None
        return self._client._get(f"{self._BASE_PATH}/next-slot", params=params)

    # Async
    async def aget_slots(self, **kwargs: Any) -> dict[str, Any]:
        params = {"profileId": kwargs.get("profile_id")} if kwargs.get("profile_id") else None
        return await self._client._aget(f"{self._BASE_PATH}/slots", params=params)
