Skip to content

Commit

Permalink
responses: Support __dict__ on all response types
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Sep 24, 2022
1 parent a4cd1b9 commit e01b270
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 119 deletions.
6 changes: 3 additions & 3 deletions valo_api/responses/account_details.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from typing import Optional

from msgspec import Struct
from valo_api.utils.dict_struct import DictStruct


class AccountCardV1(Struct):
class AccountCardV1(DictStruct):
id: str
small: str
large: str
wide: str


class AccountDetailsV1(Struct):
class AccountDetailsV1(DictStruct):
puuid: str
region: str
account_level: int
Expand Down
6 changes: 3 additions & 3 deletions valo_api/responses/competitive_updates_raw.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List

from msgspec import Struct
from valo_api.utils.dict_struct import DictStruct


class CompetitiveMatchRaw(Struct):
class CompetitiveMatchRaw(DictStruct):
MatchID: str
MapID: str
SeasonID: str
Expand All @@ -18,7 +18,7 @@ class CompetitiveMatchRaw(Struct):
AFKPenalty: int


class CompetitiveUpdatesRawV1(Struct):
class CompetitiveUpdatesRawV1(DictStruct):
Version: int
Subject: str
Matches: List[CompetitiveMatchRaw]
8 changes: 4 additions & 4 deletions valo_api/responses/content.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from typing import Dict, List, Optional

from msgspec import Struct
from valo_api.utils.dict_struct import DictStruct


class Entity(Struct):
class Entity(DictStruct):
name: str
id: str
assetName: str
assetPath: Optional[str] = None
localizedNames: Optional[Dict[str, str]] = None


class Act(Struct):
class Act(DictStruct):
id: str
parentId: str
type: str
Expand All @@ -20,7 +20,7 @@ class Act(Struct):
localizedNames: Optional[Dict[str, str]] = None


class ContentV1(Struct):
class ContentV1(DictStruct):
version: str
characters: List[Entity]
maps: List[Entity]
Expand Down
6 changes: 3 additions & 3 deletions valo_api/responses/error_response.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from typing import Dict, List, Optional

from msgspec import Struct
from valo_api.utils.dict_struct import DictStruct


class Error(Struct):
class Error(DictStruct):
code: Optional[int] = None
message: Optional[str] = None
details: Optional[str] = None


class ErrorResponse(Struct):
class ErrorResponse(DictStruct):
status: Optional[int] = None
errors: Optional[List[Error]] = None
headers: Optional[Dict[str, str]] = None
8 changes: 4 additions & 4 deletions valo_api/responses/leaderboard.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List, Optional

from msgspec import Struct
from valo_api.utils.dict_struct import DictStruct


class LeaderboardPlayerV1(Struct):
class LeaderboardPlayerV1(DictStruct):
PlayerCardID: str
TitleID: str
IsBanned: bool
Expand All @@ -17,7 +17,7 @@ class LeaderboardPlayerV1(Struct):
competitiveTier: int


class LeaderboardPlayerV2(Struct):
class LeaderboardPlayerV2(DictStruct):
PlayerCardID: str
TitleID: str
IsBanned: bool
Expand All @@ -31,7 +31,7 @@ class LeaderboardPlayerV2(Struct):
competitiveTier: int


class LeaderboardV2(Struct):
class LeaderboardV2(DictStruct):
total_players: int
radiant_threshold: int
immortal_3_threshold: int
Expand Down
55 changes: 27 additions & 28 deletions valo_api/responses/match_details_raw.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from typing import Dict, List, Optional

from msgspec import Struct

from valo_api.responses.match_history import Location
from valo_api.utils.dict_struct import DictStruct


class MatchInfoRaw(Struct):
class MatchInfoRaw(DictStruct):
matchId: str
mapId: str
gamePodId: str
Expand All @@ -29,21 +28,21 @@ class MatchInfoRaw(Struct):
shouldMatchDisablePenalties: Optional[bool] = None


class PlayerPlatformInfoRaw(Struct):
class PlayerPlatformInfoRaw(DictStruct):
platformType: str
platformOS: str
platformOSVersion: str
platformChipset: str


class PlayerAbilityCastsRaw(Struct):
class PlayerAbilityCastsRaw(DictStruct):
grenadeCasts: int
ability1Casts: int
ability2Casts: int
ultimateCasts: int


class PlayerStatsRaw(Struct):
class PlayerStatsRaw(DictStruct):
score: int
roundsPlayed: int
kills: int
Expand All @@ -53,60 +52,60 @@ class PlayerStatsRaw(Struct):
abilityCasts: Optional[PlayerAbilityCastsRaw] = None


class PlayerRoundDamageRaw(Struct):
class PlayerRoundDamageRaw(DictStruct):
round: int
receiver: str
damage: int


class PlayerBehaviorFactorsRaw(Struct):
class PlayerBehaviorFactorsRaw(DictStruct):
afkRounds: float
damageParticipationOutgoing: Optional[int] = None
friendlyFireIncoming: Optional[int] = None
friendlyFireOutgoing: Optional[float] = None
stayedInSpawnRounds: Optional[float] = None


class PlayerBasicMovementRaw(Struct):
class PlayerBasicMovementRaw(DictStruct):
idleTimeMillis: int
objectiveCompleteTimeMillis: int


class PlayerBasicGunSkillRaw(Struct):
class PlayerBasicGunSkillRaw(DictStruct):
idleTimeMillis: int
objectiveCompleteTimeMillis: int


class PlayerAdaptiveBotsRaw(Struct):
class PlayerAdaptiveBotsRaw(DictStruct):
idleTimeMillis: int
objectiveCompleteTimeMillis: int
adaptiveBotAverageDurationMillisAllAttempts: int
adaptiveBotAverageDurationMillisFirstAttempt: int
killDetailsFirstAttempt: Optional[dict]


class PlayerAbilityRaw(Struct):
class PlayerAbilityRaw(DictStruct):
idleTimeMillis: int
objectiveCompleteTimeMillis: int


class PlayerBombPlantRaw(Struct):
class PlayerBombPlantRaw(DictStruct):
idleTimeMillis: int
objectiveCompleteTimeMillis: int


class PlayerDefendBombSiteRaw(Struct):
class PlayerDefendBombSiteRaw(DictStruct):
idleTimeMillis: int
objectiveCompleteTimeMillis: int
success: bool


class PlayerSettingStatusRaw(Struct):
class PlayerSettingStatusRaw(DictStruct):
isMouseSensitivityDefault: bool
isCrosshairDefault: bool


class PlayerExperienceDetailsRaw(Struct):
class PlayerExperienceDetailsRaw(DictStruct):
basicMovement: PlayerBasicMovementRaw
basicGunSkill: PlayerBasicGunSkillRaw
adaptiveBots: PlayerAdaptiveBotsRaw
Expand All @@ -116,7 +115,7 @@ class PlayerExperienceDetailsRaw(Struct):
settingStatus: PlayerSettingStatusRaw


class MatchPlayersRaw(Struct):
class MatchPlayersRaw(DictStruct):
subject: str
gameName: str
tagLine: str
Expand All @@ -135,26 +134,26 @@ class MatchPlayersRaw(Struct):
sessionPlaytimeMinutes: Optional[int] = None


class MatchTeamRaw(Struct):
class MatchTeamRaw(DictStruct):
teamId: str
won: bool
roundsPlayed: int
numPoints: int


class PlayerLocationsRaw(Struct):
class PlayerLocationsRaw(DictStruct):
subject: str
viewRadians: float
location: Location


class KillFinishingDamageRaw(Struct):
class KillFinishingDamageRaw(DictStruct):
damageType: str
damageItem: str
isSecondaryFireMode: bool


class PlayerKillsRaw(Struct):
class PlayerKillsRaw(DictStruct):
gameTime: int
roundTime: int
killer: str
Expand All @@ -165,15 +164,15 @@ class PlayerKillsRaw(Struct):
finishingDamage: KillFinishingDamageRaw


class PlayerDamageRaw(Struct):
class PlayerDamageRaw(DictStruct):
receiver: str
damage: int
legshots: int
bodyshots: int
headshots: int


class PlayerEconomyRaw(Struct):
class PlayerEconomyRaw(DictStruct):
loadoutValue: int
weapon: str
armor: str
Expand All @@ -182,14 +181,14 @@ class PlayerEconomyRaw(Struct):
subject: Optional[str] = None


class PlayerAbilityEffectsRaw(Struct):
class PlayerAbilityEffectsRaw(DictStruct):
grenadeEffects: Optional[dict]
ability1Effects: Optional[dict]
ability2Effects: Optional[dict]
ultimateEffects: Optional[dict]


class RoundPlayerStatsRaw(Struct):
class RoundPlayerStatsRaw(DictStruct):
subject: str
kills: List[PlayerKillsRaw]
damage: List[PlayerDamageRaw]
Expand All @@ -201,12 +200,12 @@ class RoundPlayerStatsRaw(Struct):
stayedInSpawn: bool


class PlayerScoreRaw(Struct):
class PlayerScoreRaw(DictStruct):
subject: str
score: int


class MatchRoundResultsRaw(Struct):
class MatchRoundResultsRaw(DictStruct):
roundNum: int
roundResult: str
roundCeremony: str
Expand All @@ -224,7 +223,7 @@ class MatchRoundResultsRaw(Struct):
defusePlayerLocations: Optional[List[PlayerLocationsRaw]] = None


class MatchDetailsRawV1(Struct):
class MatchDetailsRawV1(DictStruct):
matchInfo: MatchInfoRaw
players: List[MatchPlayersRaw]
bots: List[dict]
Expand Down
Loading

0 comments on commit e01b270

Please sign in to comment.