/
responses.go
109 lines (98 loc) · 4.18 KB
/
responses.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
package server
import "time"
// StatScheduleResponse represents the structure of the JSON returned from http
// calls to the mlb stats API (https://statsapi.mlb.com/api/v1/schedule)
type StatScheduleResponse struct {
Copyright string `json:"copyright"`
TotalItems int `json:"totalItems"`
TotalEvents int `json:"totalEvents"`
TotalGames int `json:"totalGames"`
TotalGamesInProgress int `json:"totalGamesInProgress"`
Dates []Date `json:"dates"`
}
// Date represents a single date from within a StatScheduleResponse
type Date struct {
Date string `json:"date"`
TotalItems int `json:"totalItems"`
TotalEvents int `json:"totalEvents"`
TotalGames int `json:"totalGames"`
TotalGamesInProgress int `json:"totalGamesInProgress"`
Games []Game `json:"games"`
Events []interface{} `json:"events"`
}
// Game represents a single game from within a StatScheduleResponse
type Game struct {
GamePk int `json:"gamePk"`
Link string `json:"link"`
GameType string `json:"gameType"`
Season string `json:"season"`
GameDate time.Time `json:"gameDate"`
OfficialDate string `json:"officialDate"`
Status Status `json:"status"`
Teams Teams `json:"teams"`
Venue Venue `json:"venue"`
Content Content `json:"content"`
IsTie bool `json:"isTie"`
GameNumber int `json:"gameNumber"`
PublicFacing bool `json:"publicFacing"`
DoubleHeader string `json:"doubleHeader"`
GamedayType string `json:"gamedayType"`
Tiebreaker string `json:"tiebreaker"`
CalendarEventID string `json:"calendarEventID"`
SeasonDisplay string `json:"seasonDisplay"`
DayNight string `json:"dayNight"`
ScheduledInnings int `json:"scheduledInnings"`
ReverseHomeAwayStatus bool `json:"reverseHomeAwayStatus"`
InningBreakLength int `json:"inningBreakLength"`
GamesInSeries int `json:"gamesInSeries"`
SeriesGameNumber int `json:"seriesGameNumber"`
SeriesDescription string `json:"seriesDescription"`
RecordSource string `json:"recordSource"`
IfNecessary string `json:"ifNecessary"`
IfNecessaryDescription string `json:"ifNecessaryDescription"`
}
// Status represents a single status from within a StatScheduleResponse.
type Status struct {
AbstractGameState string `json:"abstractGameState"`
CodedGameState string `json:"codedGameState"`
DetailedState string `json:"detailedState"`
StatusCode string `json:"statusCode"`
StartTimeTBD bool `json:"startTimeTBD"`
AbstractGameCode string `json:"abstractGameCode"`
}
// Teams represents both the away and home teams from within a StatScheduleResponse.
type Teams struct {
Away Team `json:"away"`
Home Team `json:"home"`
}
// Team represents team data from within a StatScheduleResponse.
type Team struct {
LeagueRecord LeagueRecord `json:"leagueRecord"`
Score int `json:"score"`
Team TeamMetadata `json:"team"`
IsWinner bool `json:"isWinner"`
SplitSquad bool `json:"splitSquad"`
SeriesNumber int `json:"seriesNumber"`
}
// LeagueRecord represents a league record from within a StatScheduleResponse.
type LeagueRecord struct {
Wins int `json:"wins"`
Losses int `json:"losses"`
Pct string `json:"pct"`
}
// TeamMetadata represents some more identifying information for a team from within a StatScheduleResponse.
type TeamMetadata struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
}
// Venue represents identifying information for venue from within a StatScheduleResponse.
type Venue struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
}
// Content contains a link to more game content from within a StatScheduleResponse.
type Content struct {
Link string `json:"link"`
}