diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b5b2936..330bec1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,8 +8,9 @@ To be released * Added ``sheet`` optional parameter to ``Tournaments.stream_results``, and fix returned typed dict. * Added ``studies.import_pgn`` to import PGN to study * Added ``tv.stream_current_game_of_channel`` to stream the current TV game of a channel +* Added ``client.account.get_timeline`` to get user timeline -Thanks to @nicvagn, @tors42, @fitztrev and @trevorbayless for their contributions to this release. +Thanks to @nicvagn, @tors42, @fitztrev, @trevorbayless, and @srachmiletter for their contributions to this release. v0.13.2 (2023-12-04) -------------------- diff --git a/README.rst b/README.rst index e3f8fbc..774aacf 100644 --- a/README.rst +++ b/README.rst @@ -65,6 +65,7 @@ Most of the API is available: client.account.get_kid_mode client.account.set_kid_mode client.account.upgrade_to_bot + client.account.get_timeline client.analysis.get_cloud_evaluation diff --git a/berserk/clients/account.py b/berserk/clients/account.py index 434785b..3a82af8 100644 --- a/berserk/clients/account.py +++ b/berserk/clients/account.py @@ -3,8 +3,9 @@ from typing import cast from .. import models -from ..types.account import AccountInformation, Preferences +from ..types.account import AccountInformation, Preferences, TimelineEvents from .base import BaseClient +from ..session import Params class Account(BaseClient): @@ -60,3 +61,17 @@ def upgrade_to_bot(self): """ path = "/api/bot/account/upgrade" self._r.post(path) + + def get_timeline(self, since: int = 1356998400070, nb: int = 15) -> TimelineEvents: + """Get your timeline events. + + Requires OAuth2 authorization. + + :param int since: timestamp to show events since, default 1356998400070 + :param int nb: max number of events to fetch, default 15 + :return: timeline events of the authenticated user + """ + path = "/api/timeline" + params: Params = {"since": since, "nb": nb} + + return cast(TimelineEvents, self._r.get(path, params=params)) diff --git a/berserk/types/account.py b/berserk/types/account.py index d6da3ee..b89ea50 100644 --- a/berserk/types/account.py +++ b/berserk/types/account.py @@ -1,6 +1,7 @@ from __future__ import annotations from datetime import datetime +from typing import Any from typing_extensions import TypedDict @@ -94,3 +95,8 @@ class Preferences(TypedDict, total=False): zen: int moveEvent: int rookCastle: int + + +class TimelineEvents(TypedDict): + entries: list[dict[str, Any]] + users: dict[str, Any]