-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
api/challenge
endpoints (#52)
* Update berserk/clients/teams.py Co-authored-by: Benedikt Werner <1benediktwerner@gmail.com> * Update README.rst * Update teams.py * add challenge endpoints * fix black formatting error * list of any * ok now all challenge endpoints have been implemented * add TypedDicts and TypedAliases * fix black and pyright errors * use pre-defined constants in common * move all literals into common * fix issues * black reformatting * add to changelog * refactor types * Use List of usernames for `create_tokens_for_multiple_users` more pythonic --------- Co-authored-by: Benedikt Werner <1benediktwerner@gmail.com> Co-authored-by: kraktus <kraktus@users.noreply.github.com>
- Loading branch information
1 parent
dd0df4c
commit dba4fe9
Showing
9 changed files
with
157 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from __future__ import annotations | ||
|
||
from typing_extensions import TypeAlias, TypedDict, NotRequired, Literal | ||
|
||
from .common import Variant, Color, OnlineLightUser | ||
from .opening_explorer import Speed | ||
|
||
ChallengeStatus: TypeAlias = Literal[ | ||
"created", | ||
"offline", | ||
"canceled", | ||
"declined", | ||
"accepted", | ||
] | ||
|
||
ChallengeDeclineReason: TypeAlias = Literal[ | ||
"generic", | ||
"later", | ||
"tooFast", | ||
"tooSlow", | ||
"timeControl", | ||
"rated", | ||
"casual", | ||
"standard", | ||
"variant", | ||
"noBot", | ||
"onlyBot", | ||
] | ||
|
||
ChallengeDirection: TypeAlias = Literal["in", "out"] | ||
|
||
|
||
class User(OnlineLightUser): | ||
"""Challenge User""" | ||
|
||
rating: NotRequired[float] | ||
provisional: NotRequired[bool] | ||
|
||
|
||
class Challenge(TypedDict): | ||
"""Information about a challenge.""" | ||
|
||
id: str | ||
url: str | ||
status: ChallengeStatus | ||
challenger: User | ||
destUser: User | None | ||
variant: Variant | ||
rated: bool | ||
speed: Speed | ||
timeControl: object | ||
color: Color | ||
perf: str | ||
direction: NotRequired[ChallengeDirection] | ||
initialFen: NotRequired[str] | ||
declineReason: str | ||
declineReasonKey: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters