-
Notifications
You must be signed in to change notification settings - Fork 89
/
channels_vips.go
88 lines (71 loc) · 2.49 KB
/
channels_vips.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
package helix
type GetChannelVipsParams struct {
UserID string `query:"user_id"`
BroadcasterID string `query:"broadcaster_id"` // required
First int `query:"first"`
After string `query:"after"`
}
type ManyChannelVips struct {
ChannelsVips []ChannelVips `json:"data"`
Pagination Pagination `json:"pagination"`
}
type ChannelVips struct {
UserID string `json:"user_id"`
UserName string `json:"user_name"`
UserLogin string `json:"user_login"`
}
type ChannelVipsResponse struct {
ResponseCommon
Data ManyChannelVips
}
type AddChannelVipParams struct {
UserID string `query:"user_id"` // required
BroadcasterID string `query:"broadcaster_id"` // required
}
type AddChannelVipResponse struct {
ResponseCommon
}
type RemoveChannelVipParams struct {
UserID string `query:"user_id"` // required
BroadcasterID string `query:"broadcaster_id"` // required
}
type RemoveChannelVipResponse struct {
ResponseCommon
}
// GetChannelVips Gets a list of the broadcaster’s VIPs.
// Required scope: channel:read:vips
func (c *Client) GetChannelVips(params *GetChannelVipsParams) (*ChannelVipsResponse, error) {
resp, err := c.get("/channels/vips", &ManyChannelVips{}, params)
if err != nil {
return nil, err
}
vips := &ChannelVipsResponse{}
resp.HydrateResponseCommon(&vips.ResponseCommon)
vips.Data.ChannelsVips = resp.Data.(*ManyChannelVips).ChannelsVips
vips.Data.Pagination = resp.Data.(*ManyChannelVips).Pagination
return vips, nil
}
// AddChannelVip Adds the specified user as a VIP in the broadcaster’s channel.
// Required scope: channel:manage:vips
// Rate Limits: The broadcaster may add a maximum of 10 VIPs within a 10-second window.
func (c *Client) AddChannelVip(params *AddChannelVipParams) (*AddChannelVipResponse, error) {
resp, err := c.post("/channels/vips", nil, params)
if err != nil {
return nil, err
}
vips := &AddChannelVipResponse{}
resp.HydrateResponseCommon(&vips.ResponseCommon)
return vips, nil
}
// RemoveChannelVip : Removes the specified user as a VIP in the broadcaster’s channel.
// Required scope: channel:manage:vips
// Rate Limits: The broadcaster may remove a maximum of 10 VIPs within a 10-second window.
func (c *Client) RemoveChannelVip(params *RemoveChannelVipParams) (*RemoveChannelVipResponse, error) {
resp, err := c.delete("/channels/vips", nil, params)
if err != nil {
return nil, err
}
vips := &RemoveChannelVipResponse{}
resp.HydrateResponseCommon(&vips.ResponseCommon)
return vips, nil
}