-
Notifications
You must be signed in to change notification settings - Fork 2
/
featured_game.go
60 lines (48 loc) · 1.79 KB
/
featured_game.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
package lol
import "fmt"
// FeaturedGameInfo is an information about a featured game
type FeaturedGameInfo struct {
BannedChampion []struct {
Champion ChampionID `json:"championId"`
PickTurn int `json:"pickTurn"`
Team int `json:"teamID"`
} `json:"bannedChampions"`
ID GameID `json:"gameId"`
GameLength int64 `json:"GameLength"`
GameMode string `json:"gameMode"`
GameQueue QueueID `json:"gameQueueConfigId"`
GameStartTime EpochMillisecond `json:"gameStartTime"`
GameType string `json:"gameType"`
Map MapID `json:"mapId"`
Observer struct {
EncryptionKey string `json:"encryptionKey"`
} `json:"observers"`
Participants []struct {
ID SummonerID `json:"summonerId"`
Name string `json:"summonerName"`
Bot bool `json:"bot"`
Champion ChampionID `json:"championId"`
ProfileIcon int64 `json:"profileIconId"`
SummonerSpell1 SummonerSpellID `json:"spell1Id"`
SummonerSpell2 SummonerSpellID `json:"spell2Id"`
TeamID int64 `json:"teamId"`
} `json:"participants"`
Platform string `json:"platformId"`
}
// FeaturedGames is a list of games that Riot Game considers worth
// spectating
type FeaturedGames struct {
Games []FeaturedGameInfo `json:"gameList"`
RefrehInterval int64 `json:"clientRefreshInterval"`
}
// GetFeaturedGames returns the currently played FeaturedGame on the region
func (a *APIEndpoint) GetFeaturedGames() (*FeaturedGames, error) {
res := &FeaturedGames{}
err := a.g.Get(fmt.Sprintf("https://%s/observer-mode/rest/featured?api_key=%s",
a.region.url,
a.key), res)
if err != nil {
return nil, fmt.Errorf("Could not fetch featured game on %s: %s", a.region.code, err)
}
return res, nil
}