-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlive_match.go
284 lines (278 loc) · 11.3 KB
/
live_match.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
package owl
import (
"fmt"
"net/http"
"time"
)
// Need to document https://api.overwatchleague.com/live-match
// query params expand=team.content&locale=en-us
type LiveMatchResponse struct {
Data struct {
LiveMatch 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"`
Content struct {
Nid int `json:"nid"`
Name string `json:"name"`
AbbreviatedName string `json:"abbreviatedName"`
ID int `json:"id"`
Description string `json:"description"`
Location string `json:"location"`
LogoLockup string `json:"logoLockup"`
TeamWebsite string `json:"teamWebsite"`
Colors []struct {
Name string `json:"name"`
Usage string `json:"usage"`
Color struct {
Color string `json:"color"`
Opacity int `json:"opacity"`
} `json:"color"`
} `json:"colors"`
Icons []struct {
Png string `json:"png"`
Svg string `json:"svg"`
Usage string `json:"usage"`
} `json:"icons"`
} `json:"content"`
} `json:"competitors"`
Scores []struct {
Value int `json:"value"`
} `json:"scores"`
ConclusionValue int `json:"conclusionValue"`
ConclusionStrategy string `json:"conclusionStrategy"`
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,omitempty"`
Attributes struct {
InstanceID string `json:"instanceID"`
Map string `json:"map"`
MapGUID string `json:"mapGuid"`
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,omitempty"`
} `json:"games"`
ClientHints []interface{} `json:"clientHints"`
Bracket struct {
ID int `json:"id"`
MatchConclusionValue int `json:"matchConclusionValue"`
MatchConclusionStrategy string `json:"matchConclusionStrategy"`
Winners int `json:"winners"`
TeamSize int `json:"teamSize"`
RepeatableMatchUps int `json:"repeatableMatchUps"`
Stage struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Title string `json:"title"`
Tournament struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Game string `json:"game"`
Featured bool `json:"featured"`
Draft bool `json:"draft"`
Handle string `json:"handle"`
Title string `json:"title"`
Series struct {
ID int `json:"id"`
} `json:"series"`
} `json:"tournament"`
} `json:"stage"`
Type string `json:"type"`
ClientHints []interface{} `json:"clientHints"`
AdvantageComparing string `json:"advantageComparing"`
ThirdPlaceMatch bool `json:"thirdPlaceMatch"`
AllowDraw bool `json:"allowDraw"`
} `json:"bracket"`
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"`
TimeToMatch int `json:"timeToMatch"`
LiveStatus string `json:"liveStatus"`
} `json:"liveMatch"`
NextMatch 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"`
Content struct {
Nid int `json:"nid"`
Name string `json:"name"`
AbbreviatedName string `json:"abbreviatedName"`
ID int `json:"id"`
Description string `json:"description"`
Location string `json:"location"`
LogoLockup string `json:"logoLockup"`
TeamWebsite string `json:"teamWebsite"`
Colors []struct {
Name string `json:"name"`
Usage string `json:"usage"`
Color struct {
Color string `json:"color"`
Opacity int `json:"opacity"`
} `json:"color"`
} `json:"colors"`
Icons []struct {
Png string `json:"png"`
Svg string `json:"svg"`
Usage string `json:"usage"`
} `json:"icons"`
} `json:"content"`
} `json:"competitors"`
Scores []struct {
Value int `json:"value"`
} `json:"scores"`
ConclusionValue int `json:"conclusionValue"`
ConclusionStrategy string `json:"conclusionStrategy"`
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"`
Attributes struct {
Map string `json:"map"`
MapGUID string `json:"mapGuid"`
} `json:"attributes"`
AttributesVersion string `json:"attributesVersion"`
State string `json:"state"`
Status string `json:"status"`
StatusReason string `json:"statusReason"`
Stats interface{} `json:"stats"`
} `json:"games"`
ClientHints []interface{} `json:"clientHints"`
Bracket struct {
ID int `json:"id"`
MatchConclusionValue int `json:"matchConclusionValue"`
MatchConclusionStrategy string `json:"matchConclusionStrategy"`
Winners int `json:"winners"`
TeamSize int `json:"teamSize"`
RepeatableMatchUps int `json:"repeatableMatchUps"`
Stage struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Title string `json:"title"`
Tournament struct {
ID int `json:"id"`
AvailableLanguages []string `json:"availableLanguages"`
Game string `json:"game"`
Featured bool `json:"featured"`
Draft bool `json:"draft"`
Handle string `json:"handle"`
Title string `json:"title"`
Series struct {
ID int `json:"id"`
} `json:"series"`
} `json:"tournament"`
} `json:"stage"`
Type string `json:"type"`
ClientHints []interface{} `json:"clientHints"`
AdvantageComparing string `json:"advantageComparing"`
ThirdPlaceMatch bool `json:"thirdPlaceMatch"`
AllowDraw bool `json:"allowDraw"`
} `json:"bracket"`
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 []interface{} `json:"videos"`
TimeToMatch int `json:"timeToMatch"`
LiveStatus string `json:"liveStatus"`
} `json:"nextMatch"`
} `json:"data"`
Meta struct {
Strings struct {
OwlLiveMatchUpcoming string `json:"owl.live-match.upcoming"`
OwlLiveMatchNow string `json:"owl.live-match.now"`
OwlLiveStreamGame string `json:"owl.live-stream.game"`
OwlLiveStreamGameOf string `json:"owl.live-stream.game-of"`
OwlLiveStreamResults string `json:"owl.live-stream.results"`
OwlLiveStreamViewMore string `json:"owl.live-stream.view-more"`
OwlLiveStreamViewLess string `json:"owl.live-stream.view-less"`
OwlLiveStreamPhoenixDisclaimer string `json:"owl.live-stream.phoenix-disclaimer"`
OwlRewardsInfoDescription string `json:"owl.rewards.info.description"`
OwlRewardsInfoDescriptionLoggedIn string `json:"owl.rewards.info.description.logged-in"`
} `json:"strings"`
} `json:"meta"`
}
// GetLiveMatch gets the current live match if one is in progress
// from the owl api.
// Endpoint: GET /live-match
// query params expand=team.content&locale=en-us
func (c *Client) GetLiveMatch() (*LiveMatchResponse, error) {
l := &LiveMatchResponse{}
req, err := http.NewRequest("GET", fmt.Sprintf("%s/live-match", c.baseURL), nil)
if err != nil {
return l, err
}
if err = c.sendRequest(req, l); err != nil {
return l, err
}
return l, nil
}