-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclub.go
49 lines (43 loc) · 1.21 KB
/
club.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
package bsapi
import (
"context"
"net/url"
)
type ClubRole string
const (
ClubRolePresident ClubRole = "president"
ClubRoleVicePresident ClubRole = "vicePresident"
ClubRoleSenior ClubRole = "senior"
ClubRoleMember ClubRole = "member"
)
type Club struct {
Tag string `json:"tag"`
Name string `json:"name"`
Description string `json:"description"`
Trophies int `json:"trophies"`
RequiredTrophies int `json:"requiredTrophies"`
Members []ClubMember `json:"members"`
Type string `json:"type"`
BadgeId int `json:"badgeId"`
}
type ClubMember struct {
Icon PlayerIcon `json:"icon"`
Tag string `json:"tag"`
Name string `json:"name"`
Trophies int `json:"trophies"`
Role ClubRole `json:"role"`
NameColor string `json:"nameColor"`
}
func (api BsApi) GetClubStats(ctx context.Context, tag string) (Club, error) {
url := "/clubs/" + url.QueryEscape(tag)
data, err := api.makeRequest(ctx, url)
if err != nil {
return Club{}, err
}
club := Club{}
err = json.Unmarshal(data, &club)
if err != nil {
return Club{}, err
}
return club, nil
}