ctfy.sdk.resources.series
client.series — a recurring contest's ladder.
1"""``client.series`` — a recurring contest's ladder.""" 2 3from __future__ import annotations 4 5from ctfy.sdk._helpers import _raise_for_status 6from ctfy.sdk.base import BaseHttpClient 7from ctfy.server.models.series import SeriesLadder, SeriesLadderHistory 8 9 10class SeriesResource: 11 """The player-facing half of a series: its ladder and one player's history. 12 13 Deliberately separate from ``client.admin.series``, which configures 14 the schedule. These two reads are public for a public weekly and 15 need no privilege at all, so putting them behind the admin resource 16 would make the ladder unreadable by the people it rates. 17 """ 18 19 def __init__(self, http: BaseHttpClient) -> None: 20 self._http = http 21 22 def ladder(self, series_id: str) -> SeriesLadder: 23 """The whole ladder, best first, ties sharing a rank.""" 24 resp = self._http.request("GET", f"/series/{series_id}/ladder") 25 _raise_for_status(resp) 26 return SeriesLadder.model_validate(resp.json()) 27 28 def ladder_history(self, series_id: str, user_id: str) -> SeriesLadderHistory: 29 """Every occurrence that moved this player's rating, newest first. 30 31 404 when the player has never been rated on this series — an 32 empty history would read as "played and never moved". 33 """ 34 resp = self._http.request("GET", f"/series/{series_id}/ladder/{user_id}") 35 _raise_for_status(resp) 36 return SeriesLadderHistory.model_validate(resp.json())
class
SeriesResource:
11class SeriesResource: 12 """The player-facing half of a series: its ladder and one player's history. 13 14 Deliberately separate from ``client.admin.series``, which configures 15 the schedule. These two reads are public for a public weekly and 16 need no privilege at all, so putting them behind the admin resource 17 would make the ladder unreadable by the people it rates. 18 """ 19 20 def __init__(self, http: BaseHttpClient) -> None: 21 self._http = http 22 23 def ladder(self, series_id: str) -> SeriesLadder: 24 """The whole ladder, best first, ties sharing a rank.""" 25 resp = self._http.request("GET", f"/series/{series_id}/ladder") 26 _raise_for_status(resp) 27 return SeriesLadder.model_validate(resp.json()) 28 29 def ladder_history(self, series_id: str, user_id: str) -> SeriesLadderHistory: 30 """Every occurrence that moved this player's rating, newest first. 31 32 404 when the player has never been rated on this series — an 33 empty history would read as "played and never moved". 34 """ 35 resp = self._http.request("GET", f"/series/{series_id}/ladder/{user_id}") 36 _raise_for_status(resp) 37 return SeriesLadderHistory.model_validate(resp.json())
The player-facing half of a series: its ladder and one player's history.
Deliberately separate from client.admin.series, which configures
the schedule. These two reads are public for a public weekly and
need no privilege at all, so putting them behind the admin resource
would make the ladder unreadable by the people it rates.
def
ladder(self, series_id: str) -> ctfy.server.models.series.SeriesLadder:
23 def ladder(self, series_id: str) -> SeriesLadder: 24 """The whole ladder, best first, ties sharing a rank.""" 25 resp = self._http.request("GET", f"/series/{series_id}/ladder") 26 _raise_for_status(resp) 27 return SeriesLadder.model_validate(resp.json())
The whole ladder, best first, ties sharing a rank.
def
ladder_history( self, series_id: str, user_id: str) -> ctfy.server.models.series.SeriesLadderHistory:
29 def ladder_history(self, series_id: str, user_id: str) -> SeriesLadderHistory: 30 """Every occurrence that moved this player's rating, newest first. 31 32 404 when the player has never been rated on this series — an 33 empty history would read as "played and never moved". 34 """ 35 resp = self._http.request("GET", f"/series/{series_id}/ladder/{user_id}") 36 _raise_for_status(resp) 37 return SeriesLadderHistory.model_validate(resp.json())
Every occurrence that moved this player's rating, newest first.
404 when the player has never been rated on this series — an empty history would read as "played and never moved".