-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusers.go
47 lines (39 loc) · 1014 Bytes
/
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
package slack
import (
"context"
"net/url"
)
type UserService struct {
client *Client
}
type User struct {
ID string `json:"id"`
Name string `json:"name"`
Updated SlackTime `json:"updated"`
Profile *UserProfile `json:"profile"`
}
type UserResponse struct {
User *User `json:"user"`
}
type UserProfile struct {
Email string `json:"email"`
Team string `json:"team"`
}
type UsersListResponse struct {
Members []*User `json:"members"`
}
func (u *UserService) List(ctx context.Context, data url.Values) (*UsersListResponse, error) {
resp := new(UsersListResponse)
err := u.client.ListResource(ctx, "/api/users.list", data, resp)
return resp, err
}
// Get information about a particular user.
// https://api.slack.com/methods/users.info
func (u *UserService) Get(ctx context.Context, data url.Values) (*User, error) {
resp := new(UserResponse)
err := u.client.ListResource(ctx, "/api/users.info", data, resp)
if err != nil {
return nil, err
}
return resp.User, nil
}