-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschedule.go
251 lines (245 loc) · 10.1 KB
/
schedule.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
package owl
import (
"fmt"
"net/http"
"time"
)
type ScheduleResponse struct {
Data struct {
StartDate string `json:"startDate"`
EndDate string `json:"endDate"`
Stages []struct {
ID int `json:"id"`
Slug string `json:"slug"`
Enabled bool `json:"enabled"`
Name string `json:"name"`
Tournaments []struct {
ID int `json:"id"`
Type string `json:"type"`
} `json:"tournaments"`
Matches []struct {
ID int `json:"id"`
Competitors []struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Handle string `json:"handle"`
Name string `json:"name"`
HomeLocation string `json:"homeLocation"`
PrimaryColor string `json:"primaryColor"`
SecondaryColor string `json:"secondaryColor"`
Game string `json:"game"`
AbbreviatedName string `json:"abbreviatedName"`
AddressCountry string `json:"addressCountry"`
Logo string `json:"logo"`
Icon string `json:"icon"`
SecondaryPhoto string `json:"secondaryPhoto"`
Type string `json:"type"`
} `json:"competitors"`
Scores []struct {
Value int `json:"value"`
} `json:"scores"`
ConclusionValue int `json:"conclusionValue"`
ConclusionStrategy string `json:"conclusionStrategy"`
Winner struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Handle string `json:"handle"`
Name string `json:"name"`
HomeLocation string `json:"homeLocation"`
PrimaryColor string `json:"primaryColor"`
SecondaryColor string `json:"secondaryColor"`
Game string `json:"game"`
AbbreviatedName string `json:"abbreviatedName"`
AddressCountry string `json:"addressCountry"`
Logo string `json:"logo"`
Icon string `json:"icon"`
SecondaryPhoto string `json:"secondaryPhoto"`
Type string `json:"type"`
} `json:"winner"`
State string `json:"state"`
Status string `json:"status"`
StatusReason string `json:"statusReason"`
Attributes struct {
} `json:"attributes"`
Games []struct {
ID int `json:"id"`
Number int `json:"number"`
Points []int `json:"points"`
Attributes struct {
InstanceID string `json:"instanceID"`
Map string `json:"map"`
MapScore struct {
Team1 int `json:"team1"`
Team2 int `json:"team2"`
} `json:"mapScore"`
} `json:"attributes"`
AttributesVersion string `json:"attributesVersion"`
State string `json:"state"`
Status string `json:"status"`
StatusReason string `json:"statusReason"`
Stats interface{} `json:"stats"`
Handle string `json:"handle"`
} `json:"games"`
ClientHints []interface{} `json:"clientHints"`
DateCreated int64 `json:"dateCreated"`
Flags []interface{} `json:"flags"`
Handle string `json:"handle"`
StartDate time.Time `json:"startDate"`
EndDate time.Time `json:"endDate"`
ShowStartTime bool `json:"showStartTime"`
ShowEndTime bool `json:"showEndTime"`
StartDateTS int64 `json:"startDateTS"`
EndDateTS int64 `json:"endDateTS"`
YoutubeID string `json:"youtubeId"`
Wins []int `json:"wins"`
Ties []int `json:"ties"`
Losses []int `json:"losses"`
Videos []struct {
Name int `json:"name"`
Description string `json:"description"`
VodLink string `json:"vodLink"`
YoutubeID string `json:"youtubeId"`
ThumbnailURL string `json:"thumbnailUrl"`
} `json:"videos"`
Tournament struct {
ID int `json:"id"`
Type string `json:"type"`
} `json:"tournament"`
} `json:"matches"`
Weeks []struct {
ID int `json:"id"`
StartDate int64 `json:"startDate"`
EndDate int64 `json:"endDate"`
Matches []struct {
ID int `json:"id"`
Competitors []struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Handle string `json:"handle"`
Name string `json:"name"`
HomeLocation string `json:"homeLocation"`
PrimaryColor string `json:"primaryColor"`
SecondaryColor string `json:"secondaryColor"`
Game string `json:"game"`
AbbreviatedName string `json:"abbreviatedName"`
AddressCountry string `json:"addressCountry"`
Logo string `json:"logo"`
Icon string `json:"icon"`
SecondaryPhoto string `json:"secondaryPhoto"`
Type string `json:"type"`
} `json:"competitors"`
Scores []struct {
Value int `json:"value"`
} `json:"scores"`
ConclusionValue int `json:"conclusionValue"`
ConclusionStrategy string `json:"conclusionStrategy"`
Winner struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Handle string `json:"handle"`
Name string `json:"name"`
HomeLocation string `json:"homeLocation"`
PrimaryColor string `json:"primaryColor"`
SecondaryColor string `json:"secondaryColor"`
Game string `json:"game"`
AbbreviatedName string `json:"abbreviatedName"`
AddressCountry string `json:"addressCountry"`
Logo string `json:"logo"`
Icon string `json:"icon"`
SecondaryPhoto string `json:"secondaryPhoto"`
Type string `json:"type"`
} `json:"winner"`
State string `json:"state"`
Status string `json:"status"`
StatusReason string `json:"statusReason"`
Attributes struct {
} `json:"attributes"`
Games []struct {
ID int `json:"id"`
Number int `json:"number"`
Points []int `json:"points"`
Attributes struct {
InstanceID string `json:"instanceID"`
Map string `json:"map"`
MapScore struct {
Team1 int `json:"team1"`
Team2 int `json:"team2"`
} `json:"mapScore"`
} `json:"attributes"`
AttributesVersion string `json:"attributesVersion"`
State string `json:"state"`
Status string `json:"status"`
StatusReason string `json:"statusReason"`
Stats interface{} `json:"stats"`
Handle string `json:"handle"`
} `json:"games"`
ClientHints []interface{} `json:"clientHints"`
DateCreated int64 `json:"dateCreated"`
Flags []interface{} `json:"flags"`
Handle string `json:"handle"`
StartDate time.Time `json:"startDate"`
EndDate time.Time `json:"endDate"`
ShowStartTime bool `json:"showStartTime"`
ShowEndTime bool `json:"showEndTime"`
StartDateTS int64 `json:"startDateTS"`
EndDateTS int64 `json:"endDateTS"`
YoutubeID string `json:"youtubeId"`
Wins []int `json:"wins"`
Ties []int `json:"ties"`
Losses []int `json:"losses"`
Videos []struct {
Name int `json:"name"`
Description string `json:"description"`
VodLink string `json:"vodLink"`
YoutubeID string `json:"youtubeId"`
ThumbnailURL string `json:"thumbnailUrl"`
} `json:"videos"`
Tournament struct {
ID int `json:"id"`
Type string `json:"type"`
} `json:"tournament"`
} `json:"matches"`
Name string `json:"name"`
} `json:"weeks"`
} `json:"stages"`
} `json:"data"`
Meta struct {
Strings struct {
OwlScheduleTitle string `json:"owl.schedule.title"`
OwlScheduleDropdownTeams string `json:"owl.schedule.dropdown.teams"`
OwlScheduleStagePreseason string `json:"owl.schedule.stage.preseason"`
OwlScheduleStageStage1 string `json:"owl.schedule.stage.stage1"`
OwlScheduleStageStage2 string `json:"owl.schedule.stage.stage2"`
OwlScheduleStageStage3 string `json:"owl.schedule.stage.stage3"`
OwlScheduleStageStage4 string `json:"owl.schedule.stage.stage4"`
OwlScheduleStagePlayoffs string `json:"owl.schedule.stage.playoffs"`
OwlScheduleStageFinals string `json:"owl.schedule.stage.finals"`
OwlScheduleStageAllStar string `json:"owl.schedule.stage.all-star"`
OwlScheduleDisclaimer1 string `json:"owl.schedule.disclaimer1"`
OwlScheduleDisclaimer2 string `json:"owl.schedule.disclaimer2"`
OwlScheduleSpoilers string `json:"owl.schedule.spoilers"`
OwlScheduleLive string `json:"owl.schedule.live"`
OwlScheduleMatchDetails string `json:"owl.schedule.match-details"`
OwlScheduleStageEnd string `json:"owl.schedule.stage-end"`
OwlScheduleToday string `json:"owl.schedule.today"`
OwlSchedulePrevWeek string `json:"owl.schedule.prev-week"`
OwlScheduleNextWeek string `json:"owl.schedule.next-week"`
OwlScheduleTitleMatch string `json:"owl.schedule.title-match"`
OwlSchedulePrizePool string `json:"owl.schedule.prize-pool"`
OwlScheduleWeek string `json:"owl.schedule.week"`
} `json:"strings"`
} `json:"meta"`
}
// GetSchedule gets the owl schedule from the OWL API
// Endpoint: GET /schedule
func (c *Client) GetSchedule() (*ScheduleResponse, error) {
s := &ScheduleResponse{}
req, err := http.NewRequest("GET", fmt.Sprintf("%s/schedule", c.baseURL), nil)
if err != nil {
return s, err
}
if err = c.sendRequest(req, s); err != nil {
return s, err
}
return s, nil
}