-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_boxscore.go
303 lines (281 loc) · 11.3 KB
/
gen_boxscore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
package baller
import (
"net/url"
)
type BoxscoreOptions struct {
StartPeriod int
EndPeriod int
StartRange int
EndRange int
RangeType int
GameID string
}
type BoxscoreResponse struct {
GameSummary []BoxscoreGameSummary
LineScore []BoxscoreLineScore
SeasonSeries []BoxscoreSeasonSeries
LastMeeting []BoxscoreLastMeeting
PlayerStats []BoxscorePlayerStats
TeamStats []BoxscoreTeamStats
OtherStats []BoxscoreOtherStats
Officials []BoxscoreOfficials
GameInfo []BoxscoreGameInfo
InactivePlayers []BoxscoreInactivePlayers
AvailableVideo []BoxscoreAvailableVideo
PlayerTrack []BoxscorePlayerTrack
PlayerTrackTeam []BoxscorePlayerTrackTeam
}
func (c *Client) Boxscore(options *BoxscoreOptions) (*BoxscoreResponse, error) {
var (
q = url.Values{}
url = baseURL + "boxscore?"
dest BoxscoreResponse
res result
)
q.Set("StartPeriod", encodeInt(options.StartPeriod))
q.Set("EndPeriod", encodeInt(options.EndPeriod))
q.Set("StartRange", encodeInt(options.StartRange))
q.Set("EndRange", encodeInt(options.EndRange))
q.Set("RangeType", encodeInt(options.RangeType))
q.Set("GameID", encodeString(options.GameID))
if err := c.do(url+q.Encode(), &res); err != nil {
return nil, err
}
err := res.unmarshalResultSets(map[string]interface{}{
"GameSummary": &dest.GameSummary,
"LineScore": &dest.LineScore,
"SeasonSeries": &dest.SeasonSeries,
"LastMeeting": &dest.LastMeeting,
"PlayerStats": &dest.PlayerStats,
"TeamStats": &dest.TeamStats,
"OtherStats": &dest.OtherStats,
"Officials": &dest.Officials,
"GameInfo": &dest.GameInfo,
"InactivePlayers": &dest.InactivePlayers,
"AvailableVideo": &dest.AvailableVideo,
"PlayerTrack": &dest.PlayerTrack,
"PlayerTrackTeam": &dest.PlayerTrackTeam,
})
if err != nil {
return nil, err
}
return &dest, nil
}
type BoxscoreGameSummary struct {
GameDateEst string `header:"GAME_DATE_EST"`
GameSequence int `header:"GAME_SEQUENCE"`
GameID string `header:"GAME_ID"`
GameStatusID int `header:"GAME_STATUS_ID"`
GameStatusText string `header:"GAME_STATUS_TEXT"`
Gamecode string `header:"GAMECODE"`
HomeTeamID int `header:"HOME_TEAM_ID"`
VisitorTeamID int `header:"VISITOR_TEAM_ID"`
Season string `header:"SEASON"`
LivePeriod int `header:"LIVE_PERIOD"`
LivePcTime string `header:"LIVE_PC_TIME"`
NatlTvBroadcasterAbbreviation string `header:"NATL_TV_BROADCASTER_ABBREVIATION"`
LivePeriodTimeBcast string `header:"LIVE_PERIOD_TIME_BCAST"`
WhStatus int `header:"WH_STATUS"`
}
type BoxscoreLineScore struct {
GameDateEst string `header:"GAME_DATE_EST"`
GameSequence int `header:"GAME_SEQUENCE"`
GameID string `header:"GAME_ID"`
TeamID int `header:"TEAM_ID"`
TeamAbbreviation string `header:"TEAM_ABBREVIATION"`
TeamCityName string `header:"TEAM_CITY_NAME"`
TeamWinsLosses string `header:"TEAM_WINS_LOSSES"`
PtsQtr1 int `header:"PTS_QTR1"`
PtsQtr2 int `header:"PTS_QTR2"`
PtsQtr3 int `header:"PTS_QTR3"`
PtsQtr4 int `header:"PTS_QTR4"`
PtsOt1 int `header:"PTS_OT1"`
PtsOt2 int `header:"PTS_OT2"`
PtsOt3 int `header:"PTS_OT3"`
PtsOt4 int `header:"PTS_OT4"`
PtsOt5 int `header:"PTS_OT5"`
PtsOt6 int `header:"PTS_OT6"`
PtsOt7 int `header:"PTS_OT7"`
PtsOt8 int `header:"PTS_OT8"`
PtsOt9 int `header:"PTS_OT9"`
PtsOt10 int `header:"PTS_OT10"`
Pts int `header:"PTS"`
}
type BoxscoreSeasonSeries struct {
GameID string `header:"GAME_ID"`
HomeTeamID int `header:"HOME_TEAM_ID"`
VisitorTeamID int `header:"VISITOR_TEAM_ID"`
GameDateEst string `header:"GAME_DATE_EST"`
HomeTeamWins int `header:"HOME_TEAM_WINS"`
HomeTeamLosses int `header:"HOME_TEAM_LOSSES"`
SeriesLeader string `header:"SERIES_LEADER"`
}
type BoxscoreLastMeeting struct {
GameID string `header:"GAME_ID"`
LastGameID string `header:"LAST_GAME_ID"`
LastGameDateEst string `header:"LAST_GAME_DATE_EST"`
LastGameHomeTeamID int `header:"LAST_GAME_HOME_TEAM_ID"`
LastGameHomeTeamCity string `header:"LAST_GAME_HOME_TEAM_CITY"`
LastGameHomeTeamName string `header:"LAST_GAME_HOME_TEAM_NAME"`
LastGameHomeTeamAbbreviation string `header:"LAST_GAME_HOME_TEAM_ABBREVIATION"`
LastGameHomeTeamPoints int `header:"LAST_GAME_HOME_TEAM_POINTS"`
LastGameVisitorTeamID int `header:"LAST_GAME_VISITOR_TEAM_ID"`
LastGameVisitorTeamCity string `header:"LAST_GAME_VISITOR_TEAM_CITY"`
LastGameVisitorTeamName string `header:"LAST_GAME_VISITOR_TEAM_NAME"`
LastGameVisitorTeamCity1 string `header:"LAST_GAME_VISITOR_TEAM_CITY1"`
LastGameVisitorTeamPoints int `header:"LAST_GAME_VISITOR_TEAM_POINTS"`
}
type BoxscorePlayerStats struct {
GameID string `header:"GAME_ID"`
TeamID int `header:"TEAM_ID"`
TeamAbbreviation string `header:"TEAM_ABBREVIATION"`
TeamCity string `header:"TEAM_CITY"`
PlayerID int `header:"PLAYER_ID"`
PlayerName string `header:"PLAYER_NAME"`
StartPosition string `header:"START_POSITION"`
Comment string `header:"COMMENT"`
Min string `header:"MIN"`
Fgm int `header:"FGM"`
Fga int `header:"FGA"`
FgPct float32 `header:"FG_PCT"`
Fg3m int `header:"FG3M"`
Fg3a int `header:"FG3A"`
Fg3Pct float32 `header:"FG3_PCT"`
Ftm int `header:"FTM"`
Fta int `header:"FTA"`
FtPct float32 `header:"FT_PCT"`
Oreb int `header:"OREB"`
Dreb int `header:"DREB"`
Reb int `header:"REB"`
Ast int `header:"AST"`
Stl int `header:"STL"`
Blk int `header:"BLK"`
To int `header:"TO"`
Pf int `header:"PF"`
Pts int `header:"PTS"`
PlusMinus float32 `header:"PLUS_MINUS"`
}
type BoxscoreTeamStats struct {
GameID string `header:"GAME_ID"`
TeamID int `header:"TEAM_ID"`
TeamName string `header:"TEAM_NAME"`
TeamAbbreviation string `header:"TEAM_ABBREVIATION"`
TeamCity string `header:"TEAM_CITY"`
Min string `header:"MIN"`
Fgm int `header:"FGM"`
Fga int `header:"FGA"`
FgPct float32 `header:"FG_PCT"`
Fg3m int `header:"FG3M"`
Fg3a int `header:"FG3A"`
Fg3Pct float32 `header:"FG3_PCT"`
Ftm int `header:"FTM"`
Fta int `header:"FTA"`
FtPct float32 `header:"FT_PCT"`
Oreb int `header:"OREB"`
Dreb int `header:"DREB"`
Reb int `header:"REB"`
Ast int `header:"AST"`
Stl int `header:"STL"`
Blk int `header:"BLK"`
To int `header:"TO"`
Pf int `header:"PF"`
Pts int `header:"PTS"`
PlusMinus float32 `header:"PLUS_MINUS"`
}
type BoxscoreOtherStats struct {
LeagueID string `header:"LEAGUE_ID"`
SeasonID string `header:"SEASON_ID"`
TeamID int `header:"TEAM_ID"`
TeamAbbreviation string `header:"TEAM_ABBREVIATION"`
TeamCity string `header:"TEAM_CITY"`
PtsPaint int `header:"PTS_PAINT"`
Pts2ndChance int `header:"PTS_2ND_CHANCE"`
PtsFb int `header:"PTS_FB"`
LargestLead int `header:"LARGEST_LEAD"`
LeadChanges int `header:"LEAD_CHANGES"`
TimesTied int `header:"TIMES_TIED"`
}
type BoxscoreOfficials struct {
OfficialID int `header:"OFFICIAL_ID"`
FirstName string `header:"FIRST_NAME"`
LastName string `header:"LAST_NAME"`
JerseyNum string `header:"JERSEY_NUM"`
}
type BoxscoreGameInfo struct {
GameDate string `header:"GAME_DATE"`
Attendance int `header:"ATTENDANCE"`
GameTime string `header:"GAME_TIME"`
}
type BoxscoreInactivePlayers struct {
PlayerID int `header:"PLAYER_ID"`
FirstName string `header:"FIRST_NAME"`
LastName string `header:"LAST_NAME"`
JerseyNum string `header:"JERSEY_NUM"`
TeamID int `header:"TEAM_ID"`
TeamCity string `header:"TEAM_CITY"`
TeamName string `header:"TEAM_NAME"`
TeamAbbreviation string `header:"TEAM_ABBREVIATION"`
}
type BoxscoreAvailableVideo struct {
GameID string `header:"GAME_ID"`
VideoAvailableFlag int `header:"VIDEO_AVAILABLE_FLAG"`
PtAvailable int `header:"PT_AVAILABLE"`
}
type BoxscorePlayerTrack struct {
GameID string `header:"GAME_ID"`
TeamID int `header:"TEAM_ID"`
TeamAbbreviation string `header:"TEAM_ABBREVIATION"`
TeamCity string `header:"TEAM_CITY"`
PlayerID int `header:"PLAYER_ID"`
PlayerName string `header:"PLAYER_NAME"`
StartPosition string `header:"START_POSITION"`
Comment string `header:"COMMENT"`
Min string `header:"MIN"`
Spd float32 `header:"SPD"`
Dist float32 `header:"DIST"`
Orbc int `header:"ORBC"`
Drbc int `header:"DRBC"`
Rbc int `header:"RBC"`
Tchs int `header:"TCHS"`
Sast int `header:"SAST"`
Ftast int `header:"FTAST"`
Pass int `header:"PASS"`
Ast int `header:"AST"`
Cfgm int `header:"CFGM"`
Cfga int `header:"CFGA"`
CfgPct float32 `header:"CFG_PCT"`
Ufgm int `header:"UFGM"`
Ufga int `header:"UFGA"`
UfgPct float32 `header:"UFG_PCT"`
FgPct float32 `header:"FG_PCT"`
Dfgm int `header:"DFGM"`
Dfga int `header:"DFGA"`
DfgPct float32 `header:"DFG_PCT"`
}
type BoxscorePlayerTrackTeam struct {
GameID string `header:"GAME_ID"`
TeamID int `header:"TEAM_ID"`
TeamNickname string `header:"TEAM_NICKNAME"`
TeamAbbreviation string `header:"TEAM_ABBREVIATION"`
TeamCity string `header:"TEAM_CITY"`
Min string `header:"MIN"`
Dist float32 `header:"DIST"`
Orbc int `header:"ORBC"`
Drbc int `header:"DRBC"`
Rbc int `header:"RBC"`
Tchs int `header:"TCHS"`
Sast int `header:"SAST"`
Ftast int `header:"FTAST"`
Pass int `header:"PASS"`
Ast int `header:"AST"`
Cfgm int `header:"CFGM"`
Cfga int `header:"CFGA"`
CfgPct float32 `header:"CFG_PCT"`
Ufgm int `header:"UFGM"`
Ufga int `header:"UFGA"`
UfgPct float32 `header:"UFG_PCT"`
FgPct float32 `header:"FG_PCT"`
Dfgm int `header:"DFGM"`
Dfga int `header:"DFGA"`
DfgPct float32 `header:"DFG_PCT"`
}