-
Notifications
You must be signed in to change notification settings - Fork 8
/
replay.go
43 lines (36 loc) · 1.06 KB
/
replay.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
package opendota
import (
"net/http"
"github.com/dghubble/sling"
)
func newReplayService(sling *sling.Sling) *ReplayService {
return &ReplayService{
sling: sling.Path("replays"),
}
}
// ReplayService provides a method for accesing replay data.
type ReplayService struct {
sling *sling.Sling
}
type replayParam struct {
MatchID []int `url:"match_id"`
}
// Replay represents a Dota 2 replay.
type Replay struct {
MatchID int64 `json:"match_id"`
Cluster int `json:"cluster"`
ReplaySalt int `json:"replay_salt"`
SeriesID int `json:"series_id"`
SeriesType int `json:"series_type"`
}
// Replays takes an array of Match IDs and returns replays for those
// matches.
// https://docs.opendota.com/#tag/replays%2Fpaths%2F~1replays%2Fget
func (s *ReplayService) Replays(matchID []int) ([]Replay, *http.Response, error) {
params := &replayParam{}
params.MatchID = matchID
replays := new([]Replay)
apiError := new(APIError)
resp, err := s.sling.New().QueryStruct(params).Receive(replays, apiError)
return *replays, resp, relevantError(err, *apiError)
}