Skip to content

Commit

Permalink
Supporter endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ManicJamie committed May 2, 2024
1 parent 59fae4d commit a02d6f0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/speedruncompy/datatypes/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class Player(Datatype):
id: str
name: str
url: OptField[str]
powerLevel: OptField[int]
powerLevel: OptField[SitePowerLevel]
color1Id: OptField[str]
color2Id: OptField[str]
"""OptField even on full `player`"""
Expand Down Expand Up @@ -512,9 +512,9 @@ class Run(Datatype):
playerIds: list[str]
valueIds: list[str]
orphaned: OptField[bool]
estimated: OptField[bool] # TODO: Figure out what this means
estimated: OptField[bool]
"""Only shown in GetModerationRuns"""
issues: OptField[Optional[list[str]]] # TODO: fails when present
issues: OptField[Optional[list[str]]]

class ChallengeStanding(Datatype):
challengeId: str
Expand Down Expand Up @@ -809,7 +809,7 @@ class Session(Datatype):
boostNextTokenDate: int
boostNextTokenAmount: int
userFollowerList: list[UserFollower]
enabledExperimentIds: list[str] # May not be this idk
enabledExperimentIds: list[str] # TODO: check
challengeModeratorList: Any # undocumented list

class ThemeSettings(Datatype):
Expand Down
49 changes: 30 additions & 19 deletions src/speedruncompy/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,36 @@ class GetThemeSettings(PostRequest[r_GetThemeSettings]):
def __init__(self, **params) -> None:
super().__init__("GetThemeSettings", r_GetThemeSettings, **params)

# Supporter
class GetUserSupporterData(PostRequest[r_GetUserSupporterData]):
"""Gets supporter data for a user. # TODO: check auth
### Mandatory:
- @userUrl
"""
def __init__(self, userUrl: str, **params) -> None:
super().__init__("GetUserSupporterData", r_GetUserSupporterData, userUrl=userUrl, **params)

class PutUserSupporterNewSubscription(PostRequest[r_PutUserSupporterNewSubscription]):
"""Get data used to construct a payment form.
## Mandatory:
- @planKey: strEnum ("monthly" or "yearly")
- @userUrl
"""
def __init__(self, planKey: SupportPlanPeriod, userUrl: str, **params) -> None:
super().__init__("PutUserSuppoprterNewSubscription", r_PutUserSupporterNewSubscription, planKey=planKey, userUrl=userUrl, **params)

class PutGameBoostGrant(PostRequest[r_PutGameBoostGrant]):
"""Adds a boost to a game.
### Mandatory:
- @gameId
- @anonymous
"""
def __init__(self, gameId: str, anonymous: bool, **params) -> None:
super().__init__("PutGameBoostGrant", r_PutGameBoostGrant, gameId=gameId, anonymous=anonymous, **params)

# To Be Sorted
class PutAdvertiseContact(PostRequest[r_Empty]):
"""Sends a request for contact to SRC for collaboration.
Expand Down Expand Up @@ -874,15 +904,6 @@ class PutUserBlock(PostRequest[r_Empty]):
def __init__(self, block: bool, blockeeId: str, **params) -> None:
super().__init__("PutUserBlock", r_Empty, block=block, blockeeId=blockeeId, **params)

class GetUserSupporterData(PostRequest[r_GetUserSupporterData]):
"""Gets supporter data for a user. # TODO: check auth
### Mandatory:
- @userUrl
"""
def __init__(self, userUrl: str, **params) -> None:
super().__init__("GetUserSupporterData", r_GetUserSupporterData, userUrl=userUrl, **params)

class PutGame(PostRequest[r_PutGame]): # TODO: needs param testing
"""Add a new game.
Expand All @@ -896,16 +917,6 @@ class PutGame(PostRequest[r_PutGame]): # TODO: needs param testing
def __init__(self, name: str, releaseDate: int, gameTypeIds: list[GameType], seriesId: str, **params) -> None:
super().__init__("PutGame", r_PutGame, name=name, releaseDate=releaseDate, gameTypeIds=gameTypeIds, seriesId=seriesId, **params)

class PutGameBoostGrant(PostRequest[r_PutGameBoostGrant]):
"""Adds a boost to a game.
### Mandatory:
- @gameId
- @anonymous
"""
def __init__(self, gameId: str, anonymous: bool, **params) -> None:
super().__init__("PutGameBoostGrant", r_PutGameBoostGrant, gameId=gameId, anonymous=anonymous, **params)

class PutGameModerator(PostRequest[r_PutGameModerator]):
"""Add a moderator to a game.
Expand Down
7 changes: 7 additions & 0 deletions src/speedruncompy/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,10 @@ class FitType(IntEnum):
FIT = 1

#endregion Theme

#region Supporter
class SupportPlanPeriod(StrEnum):
MONTHLY = "monthly"
YEARLY = "yearly"

#endregion Supporter
4 changes: 4 additions & 0 deletions src/speedruncompy/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ class r_GetUserSupporterData(Datatype):
supporterEndDate: int
boostEndDate: int

class r_PutUserSupporterNewSubscription(Datatype):
subscription: SupporterSubscription
paymentIntentClientSecret: str

class r_PutAuthLogin(Datatype):
loggedIn: bool
tokenChallengeSent: OptField[bool]
Expand Down

0 comments on commit a02d6f0

Please sign in to comment.