from __future__ import annotations

from typing import TYPE_CHECKING, Dict
from urllib.parse import quote

if TYPE_CHECKING:
    from .._core._http_client import APIResponse, AsyncHttpClient, PaginatedResponse, SyncHttpClient


class GameStats_:
    """Sync game stats snapshots resource."""

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

    def list_versions(self) -> APIResponse:
        return self._client.get("/v1/game-stats/versions")

    def list_firearms(self, version: str, params: Dict | None = None) -> PaginatedResponse:
        return self._client.get_paginated(
            f"/v1/game-stats/versions/{quote(version, safe='')}/firearms", query=params
        )

    def get_firearm(self, version: str, id: str) -> APIResponse:
        return self._client.get(
            f"/v1/game-stats/versions/{quote(version, safe='')}/firearms/{quote(id, safe='')}"
        )


class AsyncGameStats_:
    """Async game stats snapshots resource."""

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

    async def list_versions(self) -> APIResponse:
        return await self._client.get("/v1/game-stats/versions")

    async def list_firearms(self, version: str, params: Dict | None = None) -> PaginatedResponse:
        return await self._client.get_paginated(
            f"/v1/game-stats/versions/{quote(version, safe='')}/firearms", query=params
        )

    async def get_firearm(self, version: str, id: str) -> APIResponse:
        return await self._client.get(
            f"/v1/game-stats/versions/{quote(version, safe='')}/firearms/{quote(id, safe='')}"
        )
