"""
Accounts resource.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
    from ..client.base import BaseClient


class AccountsResource:
    """Resource for managing connected social accounts."""

    _BASE_PATH = "/v1/accounts"

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

    def list(self, *, profile_id: str | None = None) -> dict[str, Any]:
        """List connected accounts."""
        params = {"profileId": profile_id} if profile_id else None
        return self._client._get(self._BASE_PATH, params=params)

    def get(self, account_id: str) -> dict[str, Any]:
        """Get an account by ID."""
        return self._client._get(f"{self._BASE_PATH}/{account_id}")

    def get_follower_stats(
        self, *, account_ids: list[str] | None = None
    ) -> dict[str, Any]:
        """Get follower statistics (requires analytics add-on)."""
        params = {"accountIds": ",".join(account_ids)} if account_ids else None
        return self._client._get(f"{self._BASE_PATH}/follower-stats", params=params)

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

    async def aget(self, account_id: str) -> dict[str, Any]:
        return await self._client._aget(f"{self._BASE_PATH}/{account_id}")
