"""Billing and credit operations."""
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from .client import Client


class Billing:
    def __init__(self, client: Client):
        self._client = client

    def balance(self) -> dict:
        """Get current credit balance."""
        return self._client.get("/v1/billing/credits/balance")

    def usage(
        self,
        period: str = "daily",
        from_date: str = "",
        to_date: str = "",
    ) -> dict:
        """Get credit usage over a time period."""
        params: dict[str, str] = {"period": period}
        if from_date:
            params["from"] = from_date
        if to_date:
            params["to"] = to_date
        return self._client.get("/v1/billing/credits/usage", params=params)

    def packs(self) -> list[dict]:
        """List available credit packs."""
        return self._client.get("/v1/billing/credits/packs")
