Skip to content

Commit

Permalink
Implement /swiss/{id}.trf endpoint (#63)
Browse files Browse the repository at this point in the history
* add swiss trf endpoint

* format it to TEXT

* changelog

---------

Co-authored-by: kraktus <[email protected]>
  • Loading branch information
Anupya and kraktus authored Nov 3, 2023
1 parent ee65d42 commit d735333
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ To be released

client.analysis.get_cloud_evaluation

client.tournaments.export_swiss_trf

Thanks to @Anupya for their contributions to this release.

v0.13.1 (2023-11-02)
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ Most of the API is available:
client.tournaments.create_swiss
client.tournaments.export_arena_games
client.tournaments.export_swiss_games
client.tournaments.export_swiss_trf
client.tournaments.arena_by_team
client.tournaments.swiss_by_team
client.tournaments.join_arena
Expand Down
11 changes: 10 additions & 1 deletion berserk/clients/tournaments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Iterator, Any, Dict, List, cast

from .. import models
from ..formats import NDJSON, NDJSON_LIST, PGN
from ..formats import NDJSON, NDJSON_LIST, PGN, TEXT
from .base import FmtClient
from ..types import ArenaResult, CurrentTournaments, SwissInfo, SwissResult
from ..types.tournaments import TeamBattleResult
Expand Down Expand Up @@ -301,6 +301,15 @@ def export_swiss_games(
converter=models.Game.convert,
)

def export_swiss_trf(self, tournament_id: str) -> str:
"""Download a tournament in the Tournament Report File format, the FIDE standard.
:param tournament_id: tournament ID
:return: tournament information in the TRF format
"""
path = f"/swiss/{tournament_id}.trf"
return self._r.get(path=path, fmt=TEXT)

def tournaments_by_user(
self, username: str, nb: int | None = None
) -> List[Dict[str, Any]]:
Expand Down

0 comments on commit d735333

Please sign in to comment.