-
Notifications
You must be signed in to change notification settings - Fork 8
/
promatch.go
46 lines (40 loc) · 1.36 KB
/
promatch.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
package opendota
import (
"net/http"
"github.com/dghubble/sling"
)
func newProMatchService(sling *sling.Sling) *ProMatchService {
return &ProMatchService{
sling: sling.Path("proMatches"),
}
}
// ProMatchService provides a method for accessing professional
// matches.
type ProMatchService struct {
sling *sling.Sling
}
// ProMatch represents a professional match in Dota 2.
type ProMatch struct {
MatchID int64 `json:"match_id"`
Duration int `json:"duration"`
StartTime int `json:"start_time"`
RadiantTeamID int `json:"radiant_team_id"`
RadiantName string `json:"radiant_name"`
DireTeamID int `json:"dire_team_id"`
DireName string `json:"dire_name"`
LeagueID int `json:"leagueid"`
LeagueName string `json:"league_name"`
SeriesID int `json:"series_id"`
SeriesType int `json:"series_type"`
RadiantScore int `json:"radiant_score"`
DireScore int `json:"dire_score"`
RadiantWin bool `json:"radiant_win"`
}
// Matches returns a collection of professional matches.
// https://docs.opendota.com/#tag/pro-matches%2Fpaths%2F~1proMatches%2Fget
func (s *ProMatchService) Matches() ([]ProMatch, *http.Response, error) {
promatches := new([]ProMatch)
apiError := new(APIError)
resp, err := s.sling.New().Receive(promatches, apiError)
return *promatches, resp, relevantError(err, *apiError)
}