Skip to content

Commit

Permalink
feat: add Client.get_population() (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackenmen authored Nov 2, 2024
1 parent 432cd94 commit a1448b9
Show file tree
Hide file tree
Showing 4 changed files with 681 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ and are not meant to be created by the user of the library.
.. autoclass:: rlapi.Playlist
:members:

.. autoclass:: rlapi.Population
:members:

.. autoclass:: rlapi.PlatformPopulation
:members:

.. autoclass:: rlapi.PopulationEntry
:members:

.. autoclass:: rlapi.PopulationPlaylist
:members:

.. autoclass:: rlapi.tier_estimates.TierEstimates
:members:

Expand Down Expand Up @@ -141,6 +153,12 @@ when interpreting data from the API.

A sequence of playlists that can advance player's season rewards.

.. data:: rlapi.KNOWN_POPULATION_PLAYLISTS
:value: {0: <PopulationPlaylist Main Menu (0) player_count=1>, ...}

A mapping of known population playlist IDs to
their `rlapi.PopulationPlaylist` objects.

Exceptions
----------

Expand Down
13 changes: 13 additions & 0 deletions rlapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
Playlist as Playlist,
SeasonRewards as SeasonRewards,
)
from .population import ( # noqa
KNOWN_POPULATION_PLAYLISTS as KNOWN_POPULATION_PLAYLISTS,
PlatformPopulation as PlatformPopulation,
Population as Population,
PopulationEntry as PopulationEntry,
PopulationPlaylist as PopulationPlaylist,
)

pkg = pkgutil.get_data(__package__, "VERSION")
__version__ = pkg.decode("ascii").strip() if pkg is not None else ""
Expand Down Expand Up @@ -72,4 +79,10 @@
"PlayerStats",
"Playlist",
"SeasonRewards",
# population
"KNOWN_POPULATION_PLAYLISTS",
"PlatformPopulation",
"Population",
"PopulationEntry",
"PopulationPlaylist",
)
19 changes: 19 additions & 0 deletions rlapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ._utils import TokenInfo, json_or_text
from .enums import Platform
from .player import Player
from .population import Population
from .typedefs import TierBreakdownType

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -597,3 +598,21 @@ async def _find_steam_ids(self, match: Match[str]) -> List[str]:
)

return ids

async def get_population(self) -> Population:
"""
Get population across different platforms and playlists.
Returns
-------
Population
Player population across different platforms and playlists.
Raises
------
HTTPException
HTTP request to Rocket League failed.
"""
data = await self._rlapi_request("/population")
return Population(data)
Loading

0 comments on commit a1448b9

Please sign in to comment.