"""
Usage resource — API usage statistics.
"""
from typing import Any, Dict, TYPE_CHECKING

if TYPE_CHECKING:
    from kronical.client import KronicalClient, AsyncKronicalClient


class UsageResource:
    """Synchronous usage methods."""

    def __init__(self, client: "KronicalClient"):
        self._client = client

    def get(self, *, days: int = 30) -> Dict[str, Any]:
        """
        GET /v1/usage — API usage statistics.

        Args:
            days: Lookback window in days (1-90).

        Returns:
            {"client_id", "client_name", "plan", "summary", "llm_cost", "endpoints", "daily"}
        """
        return self._client.request("GET", "/v1/usage", params={"days": days})


class AsyncUsageResource:
    """Asynchronous usage methods."""

    def __init__(self, client: "AsyncKronicalClient"):
        self._client = client

    async def get(self, *, days: int = 30) -> Dict[str, Any]:
        """GET /v1/usage — API usage statistics."""
        return await self._client.request("GET", "/v1/usage", params={"days": days})
