/
matches.go
80 lines (72 loc) · 2.99 KB
/
matches.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
package mock
import (
"fmt"
"strings"
"github.com/bshore/go-hirez/models"
)
// GetMatchDetails returns the statistics for a particular completed match.
func (a *APIClient) GetMatchDetails(matchID string) ([]models.MatchPlayer, error) {
resp, err := a.makeRequest("getmatchdetails", matchID, []models.MatchPlayer{})
if err != nil {
return nil, err
}
var output []models.MatchPlayer
err = a.unmarshalResponse(resp, &output)
return output, err
}
// GetMatchDetailsBatch returns the statistics for a particular set of completed matches. (limit batch query to 5-10 matchIDs)
func (a *APIClient) GetMatchDetailsBatch(matchIDs []string) ([]models.MatchPlayer, error) {
if len(matchIDs) > 10 {
return nil, fmt.Errorf("per API docs, the list of matchIDs should contain no more than 10")
}
resp, err := a.makeRequest("getmatchdetailsbatch", strings.Join(matchIDs, ","), []models.MatchPlayer{})
if err != nil {
return nil, err
}
var output []models.MatchPlayer
err = a.unmarshalResponse(resp, &output)
return output, err
}
// GetOrganizedMatchDetailsBatch is the same as GetMatchDetailsBatch(), except it groups the players by match. (limit batch query to 5-10 matchIDs)
// NOTE: This method is currently unimplemented due to issues generating a slice of slice of structs
func (a *APIClient) GetOrganizedMatchDetailsBatch(matchIDs []string) ([][]models.MatchPlayer, error) {
return nil, nil
}
// GetMatchPlayerDetails returns player information for a live match.
func (a *APIClient) GetMatchPlayerDetails(matchID string) ([]models.LiveMatchPlayer, error) {
resp, err := a.makeRequest("getmatchplayerdetails", matchID, []models.LiveMatchPlayer{})
if err != nil {
return nil, err
}
var output []models.LiveMatchPlayer
err = a.unmarshalResponse(resp, &output)
return output, err
}
/*
GetMatchIDsByQueue lists all MatchIDs for a particular match queue.
- queueID can be referened by constants defined in this package (eg, hirezapi.ConquestRanked).
- date must be formatted/formattable by hirezapi.DateFormat (yyyyMMdd).
- hour may be "0" - "23" and optionally may contain a ten minute window separated by a comma (eg, "6,30").
- hour may also be "-1" to fetch the whole day, but may stall/fail due to the amount of data.
*/
func (a *APIClient) GetMatchIDsByQueue(queueID, date, hour string) ([]models.Match, error) {
path := fmt.Sprintf("%s/%s/%s", queueID, date, hour)
resp, err := a.makeRequest("getmatchidsbyqueue", path, []models.Match{})
if err != nil {
return nil, err
}
var output []models.Match
err = a.unmarshalResponse(resp, &output)
return output, err
}
// GetQueueStats returns match summary stats for a player + queue, grouped by Gods played.
func (a *APIClient) GetQueueStats(player, queueID string) ([]models.PlayerGodQueueStat, error) {
path := fmt.Sprintf("%s/%s", player, queueID)
resp, err := a.makeRequest("getqueuestats", path, []models.PlayerGodQueueStat{})
if err != nil {
return nil, err
}
var output []models.PlayerGodQueueStat
err = a.unmarshalResponse(resp, &output)
return output, err
}