-
Notifications
You must be signed in to change notification settings - Fork 8
/
record.go
35 lines (29 loc) · 924 Bytes
/
record.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
package opendota
import (
"net/http"
"github.com/dghubble/sling"
)
func newRecordService(sling *sling.Sling) *RecordService {
return &RecordService{
sling: sling.Path("records/"),
}
}
// RecordService provides a method for accessing records for a field.
type RecordService struct {
sling *sling.Sling
}
// Record represents a record for a field.
type Record struct {
MatchID string `json:"match_id"`
StartTime string `json:"start_time"`
HeroID string `json:"hero_id"`
Score string `json:"score"`
}
// Records takes a field and returns the records for that field.
// https://docs.opendota.com/#tag/records%2Fpaths%2F~1records~1%7Bfield%7D%2Fget
func (s *RecordService) Records(field string) ([]Record, *http.Response, error) {
record := new([]Record)
apiError := new(APIError)
resp, err := s.sling.New().Get(field).Receive(record, apiError)
return *record, resp, relevantError(err, *apiError)
}