-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.go
124 lines (103 loc) · 2.93 KB
/
users.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
package twch
import (
"fmt"
)
type Users struct {
client *Client
}
type User struct {
ID *int `json:"_id,omitempty"`
Type *string `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
DisplayName *string `json:"display_name,omitempty"`
Logo *string `json:"logo,omitempty"`
Bio *string `json:"bio,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
UpdatedAt *string `json:"updated_at,omitempty"`
Email *string `json:"email,omitempty"`
Partnered *bool `json:"partnered,omitempty"`
Staff *bool `json:"staff,omitempty"`
}
// GetUser returns the public profile of a given Twitch user
func (u *Users) GetUser(username string) (user *User, resp *Response, err error) {
url := fmt.Sprintf("users/%s", username)
req, err := u.client.NewRequest("GET", url)
if err != nil {
return
}
user = new(User)
resp, err = u.client.Do(req, user)
if err != nil {
return
}
return
}
// GetCurrentUser returns the authenticated user with email and partner info.
// Requires the `user_read` authentication scope.
func (u *Users) GetCurrentUser() (user *User, resp *Response, err error) {
req, err := u.client.NewRequest("GET", "user")
if err != nil {
return
}
user = new(User)
resp, err = u.client.Do(req, user)
if err != nil {
return
}
return
}
// ListFollowedStreams returns a list of the streams the authenticated user follows.
// Requires the `user_read` authentication scope.
func (u *Users) ListFollowedStreams(opts *RequestOptions) (s []Stream, resp *Response, err error) {
url, err := appendOptions("streams/followed", opts)
if err != nil {
return
}
req, err := u.client.NewRequest("GET", url)
if err != nil {
return
}
r := new(streamList)
resp, err = u.client.Do(req, r)
if err != nil {
return
}
s = r.Streams
return
}
// ListFollowedVideos returns a list of videos created by channels the
// authenticated user is following.
// Requires the `user_read` authentication scope.
func (u *Users) ListFollowedVideos(opts *ListOptions) (videos []Video, resp *Response, err error) {
url, err := appendOptions("videos/followed", opts)
if err != nil {
return
}
req, err := u.client.NewRequest("GET", url)
if err != nil {
return
}
r := new(videosResponse)
resp, err = u.client.Do(req, r)
if err != nil {
return
}
videos = r.Videos
return
}
func (u *Users) ListFollowedChannels(user string) (ch []Channel, resp *Response, err error) {
// "users/:user/follows/channels"
return nil, nil, nil
}
func (u *Users) IsFollowing(user, channel string) (ch *Channel, resp *Response, err error) {
// "users/:user/follows/channels/:target"
return nil, nil, nil
}
func (u *Users) FollowChannel(user, channel string) (ch *Channel, resp *Response, err error) {
// PUT "users/:user/follows/channels/:target"
return nil, nil, nil
}
func (u *Users) UnfollowChannel(user, channel string) (err error) {
// DELETE "users/:user/follows/channels/:target"
return nil
}