-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannels.go
158 lines (132 loc) · 4.38 KB
/
channels.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package twch
import (
"fmt"
)
type Channels struct {
client *Client
}
type editorsResponse struct {
Users []User `json:"users,omitempty"`
}
type Channel struct {
ID *int `json:"_id,omitempty"`
DisplayName *string `json:"display_name,omitempty"`
Name *string `json:"name,omitempty"`
Title *string `json:"title,omitempty"`
Game *string `json:"game,omitempty"`
Delay *int `json:"delay,omitempty"`
StreamKey *string `json:"stream_key,omitempty"`
Teams []Team `json:"teams,omitempty"`
Status *string `json:"status,omitempty"`
Banner *string `json:"banner,omitempty"`
ProfileBanner *string `json:"profile_banner,omitempty"`
ProfileBannerBackgroundColor *string `json:"profile_banner_background_color,omitempty"`
VideoBanner *string `json:"video_banner,omitempty"`
Background *string `json:"background,omitempty"`
Logo *string `json:"logo,omitempty"`
URL *string `json:"url,omitempty"`
Login *string `json:"login,omitempty"`
Email *string `json:"email,omitempty"`
Mature *bool `json:"mature,omitempty"`
Language *string `json:"language,omitempty"`
BroadcasterLanguage *string `json:"broadcaster_language,omitempty"`
Partner *bool `json:"partner,omitempty"`
Views *int `json:"views,omitempty"`
Followers *int `json:"followers,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
UpdatedAt *string `json:"updated_at,omitempty"`
}
type ChannelOptions struct {
Status string `url:"status,omitempty"`
Game string `url:"game,omitempty"`
Delay string `url:"deplay,omitempty"`
}
type CommericalOptions struct {
Length string `url:"length,omitempty"`
}
// GetChannel returns a channel by name
func (c *Channels) GetChannel(channel string) (ch *Channel, resp *Response, err error) {
url := fmt.Sprintf("channels/%s", channel)
req, err := c.client.NewRequest("GET", url)
if err != nil {
return
}
ch = new(Channel)
resp, err = c.client.Do(req, ch)
if err != nil {
return
}
return
}
// GetUserChannel returns the channel for the authenticated user
// Requires the `channel_read` authentication scope to be approved
func (c *Channels) GetUserChannel() (ch *Channel, resp *Response, err error) {
req, err := c.client.NewRequest("GET", "channel")
if err != nil {
return
}
ch = new(Channel)
resp, err = c.client.Do(req, ch)
if err != nil {
return
}
return
}
// ListChannelEditors returns a list of user objects associated with the channel
// as "editor" status.
// This method requires the `channel_read` authentication scope
func (c *Channels) ListChannelEditors(channel string) (u []User, resp *Response, err error) {
url := fmt.Sprintf("channels/%s/editors", channel)
req, err := c.client.NewRequest("GET", url)
if err != nil {
return
}
e := new(editorsResponse)
resp, err = c.client.Do(req, e)
if err != nil {
return
}
u = e.Users
return
}
// ListChannelTeams returns a list of teams for the given channel
func (c *Channels) ListChannelTeams(channel string) (t []Team, resp *Response, err error) {
url := fmt.Sprintf("channels/%s/teams", channel)
req, err := c.client.NewRequest("GET", url)
if err != nil {
return
}
e := new(teamsResponse)
resp, err = c.client.Do(req, e)
if err != nil {
return
}
t = e.Teams
return
}
func (c *Channels) UpdateChannel(channel string) error {
// PUT "channels/:channel"
return nil
}
// ResetStreamKey reset's an authenticated channel's stream key
// Requires the `channel_stream` authentication scope
func (c *Channels) ResetStreamKey(channel string) (err error) {
url := fmt.Sprintf("channels/%s/stream_key", channel)
req, err := c.client.NewRequest("DELETE", url)
if err != nil {
return
}
_, err = c.client.Do(req, nil)
if err != nil {
return
}
return
}
func (c *Channels) StartCommercial(channel string) error {
// POST "channels/:channel/commerical"
return nil
}
func (c *Channels) GetChannelFollowers(channel string) ([]Follow, error) {
// "channels/:channel/follows"
return nil, nil
}