-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlabels.go
More file actions
44 lines (36 loc) · 1.24 KB
/
labels.go
File metadata and controls
44 lines (36 loc) · 1.24 KB
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
package goclash
import (
"net/http"
"github.com/bytedance/sonic"
)
type LabelsData struct {
Paging *Paging `json:"paging,omitempty"`
Labels []Label `json:"items,omitempty"`
}
type Label struct {
IconUrls ImageURLs `json:"iconUrls,omitempty"`
Name string `json:"name,omitempty"`
ID int `json:"id,omitempty"`
}
// GetPlayerLabels returns a paginated list of player labels. Pass params=nil to get all labels.
func (h *Client) GetPlayerLabels(params *PagingParams) (*PaginatedResponse[Label], error) {
req := h.withPaging(h.withAuth(h.newDefaultRequest()), params)
data, err := h.do(http.MethodGet, LabelsEndpoint.Build("players"), req, true)
if err != nil {
return nil, err
}
var labels *PaginatedResponse[Label]
err = sonic.Unmarshal(data, &labels)
return labels, err
}
// GetClanLabels returns a paginated list of clan labels. Pass params=nil to get all labels.
func (h *Client) GetClanLabels(params *PagingParams) (*PaginatedResponse[Label], error) {
req := h.withPaging(h.withAuth(h.newDefaultRequest()), params)
data, err := h.do(http.MethodGet, LabelsEndpoint.Build("clans"), req, true)
if err != nil {
return nil, err
}
var labels *PaginatedResponse[Label]
err = sonic.Unmarshal(data, &labels)
return labels, err
}