This repository was 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 pathUserAccessLevels.go
52 lines (46 loc) · 1.58 KB
/
UserAccessLevels.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
package hitGox
import (
"bytes"
"encoding/json"
"fmt"
just "github.com/toby3d/hitGox/tools"
)
// AccessLevels is about permissions of user on channel.
type AccessLevels struct {
AccessUserID string `json:"access_user_id"`
Account string `json:"account"`
Admin string `json:"admin"`
Broadcast string `json:"broadcast"`
Chat string `json:"chat"`
Following string `json:"following"`
Inbox string `json:"inbox"`
IsFollower bool `json:"isFollower"`
IsSubscriber bool `json:"isSubscriber"`
Livestreams string `json:"livestreams"`
Partner string `json:"partner"`
Payments string `json:"payments"`
Recordings string `json:"recordings"`
Revenues string `json:"revenues"`
Settings string `json:"settings"`
Statistics string `json:"statistics"`
Subscriptions string `json:"subscriptions"`
Superadmin string `json:"superadmin"`
Teams string `json:"teams"`
UserID string `json:"user_id"`
Videos string `json:"videos"`
}
// GetUserAccessLevels return access levels that auth has in channel.
//
// If you have never been granted Moderator or Editor in channel, this API will only return IsSubscriber and IsFollower.
func (account *Account) GetUserAccessLevels(channel string) (*AccessLevels, error) {
url := fmt.Sprintf(APIEndpoint, fmt.Sprint("user/access/", channel, "/", account.AuthToken))
resp, err := just.GET(url, nil)
if err != nil {
return nil, err
}
var obj AccessLevels
if err = json.NewDecoder(bytes.NewReader(resp)).Decode(&obj); err != nil {
return nil, err
}
return &obj, nil
}