-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteams.go
61 lines (50 loc) · 1.24 KB
/
teams.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
package twch
import (
"fmt"
)
type Teams struct {
client *Client
}
type Team struct {
ID *int `json:"_id,omitempty"`
Name *string `json:"name,omitempty"`
Info *string `json:"info,omitempty"`
DisplayName *string `json:"display_name,omitempty"`
Logo *string `json:"logo,omitempty"`
Banner *string `json:"banner,omitempty"`
Background *string `json:"background,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
UpdatedAt *string `json:"updated_at,omitempty"`
}
type teamsResponse struct {
Teams []Team `json:"teams,omitempty"`
*listLinks
}
// ListTeams returns a list of teams that are active on Twitch
func (t *Teams) ListTeams() (teams []Team, resp *Response, err error) {
req, err := t.client.NewRequest("GET", "teams")
if err != nil {
return
}
r := new(teamsResponse)
resp, err = t.client.Do(req, r)
if err != nil {
return
}
teams = r.Teams
return
}
// GetTeam returns a team for the passed team name
func (t *Teams) GetTeam(team string) (r *Team, resp *Response, err error) {
url := fmt.Sprintf("teams/%s", team)
req, err := t.client.NewRequest("GET", url)
if err != nil {
return
}
r = new(Team)
resp, err = t.client.Do(req, r)
if err != nil {
return
}
return
}