This repository has been archived by the owner on Jun 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetTeam.go
78 lines (71 loc) · 2.16 KB
/
GetTeam.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
package hitGox
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
just "github.com/toby3d/hitGox/tools"
f "github.com/valyala/fasthttp"
)
// Team is about group information.
type Team struct {
Info struct {
GroupID string `json:"group_id"`
FounderName string `json:"founder_name"`
GroupName string `json:"group_name"`
GroupDisplayName string `json:"group_display_name"`
GroupText string `json:"group_text"`
GroupLogoSmall string `json:"group_logo_small"`
GroupLogoLarge string `json:"group_logo_large"`
GroupCover string `json:"group_cover"`
MembersTotal int `json:"members_total"`
} `json:"info"`
// Media struct{
// Livestream []??
// Video []???
// }
Members []struct {
Followers string `json:"followers"`
Videos string `json:"videos"`
Recordings string `json:"recordings"`
Teams string `json:"teams"`
UserID string `json:"user_id"`
UserName string `json:"user_name"`
UserStatus string `json:"user_status"`
UserLogo string `json:"user_logo"`
UserCover string `json:"user_cover"`
UserLogoSmall string `json:"user_logo_small"`
UserPartner string `json:"user_partner"`
Admin string `json:"admin"`
Enabled string `json:"enabled"`
IsDefault string `json:"is_default"`
RevenuesEnabled string `json:"revenues_enabled"`
GroupRole string `json:"group_role"`
GroupAccepted bool `json:"group_accepted"`
} `json:"members"`
}
// GetTeam returns a team object for team.
func GetTeam(team, mediaType string, media, liveOnly, partner bool) (*Team, error) {
var args f.Args
switch {
case media:
args.Add("media", strconv.FormatBool(media))
fallthrough
case mediaType != "":
args.Add("media_type", mediaType)
fallthrough
case liveOnly:
args.Add("liveonly", strconv.FormatBool(liveOnly))
fallthrough
case partner:
args.Add("partner", strconv.FormatBool(partner))
}
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("/team/", team))
resp, err := just.GET(url, &args)
if err != nil {
return nil, err
}
var obj Team
json.NewDecoder(bytes.NewReader(resp)).Decode(&obj)
return &obj, nil
}