Skip to content

Commit e9793ca

Browse files
authored
Merge pull request #248 from gitknr/fix/abs-challenges-model
2 parents 57cbf46 + 65c800a commit e9793ca

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

mlbstatsapi/models/game/gamedata/attributes.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,42 @@ class GameReview(MLBBaseModel):
200200
home: ReviewInfo
201201

202202

203+
class AbsChallengeInfo(MLBBaseModel):
204+
"""
205+
A class to represent ABS challenge info for each team in this game.
206+
207+
Attributes
208+
----------
209+
used_successful : int
210+
How many successful ABS challenges were used.
211+
used_failed : int
212+
How many failed ABS challenges were used.
213+
remaining : int
214+
How many ABS challenges are remaining.
215+
"""
216+
used_successful: int = Field(alias="usedSuccessful")
217+
used_failed: int = Field(alias="usedFailed")
218+
remaining: int
219+
220+
221+
class AbsChallenges(MLBBaseModel):
222+
"""
223+
A class to represent ABS challenge information for this game.
224+
225+
Attributes
226+
----------
227+
has_challenges : bool
228+
If ABS challenges are available.
229+
away : AbsChallengeInfo
230+
Away team ABS challenge info.
231+
home : AbsChallengeInfo
232+
Home team ABS challenge info.
233+
"""
234+
has_challenges: bool = Field(alias="hasChallenges")
235+
away: AbsChallengeInfo
236+
home: AbsChallengeInfo
237+
238+
203239
class GameFlags(MLBBaseModel):
204240
"""
205241
A class to represent the flags for this game.

mlbstatsapi/models/game/gamedata/gamedata.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
GameWeather,
1212
GameInfo,
1313
GameReview,
14+
AbsChallenges,
1415
GameFlags,
1516
GameProbablePitchers,
1617
MoundVisits,
@@ -57,8 +58,8 @@ class GameData(MLBBaseModel):
5758
Secondary data caster for this game.
5859
mound_visits : MoundVisits
5960
Mound visits for this game.
60-
abs_challenges : List[dict]
61-
ABS challenges for this game.
61+
abs_challenges : AbsChallenges
62+
ABS challenge information for this game.
6263
"""
6364
game: GameDataGame
6465
datetime: GameDatetime
@@ -77,7 +78,7 @@ class GameData(MLBBaseModel):
7778
official_scorer: Optional[Person] = Field(default=None, alias="officialScorer")
7879
primary_data_caster: Optional[Person] = Field(default=None, alias="primaryDataCaster")
7980
secondary_data_caster: Optional[Person] = Field(default=None, alias="secondaryDataCaster")
80-
abs_challenges: Optional[List[dict]] = Field(default=None, alias="absChallenges")
81+
abs_challenges: Optional[AbsChallenges] = Field(default=None, alias="absChallenges")
8182

8283
@model_validator(mode='before')
8384
@classmethod

0 commit comments

Comments
 (0)