-
Notifications
You must be signed in to change notification settings - Fork 59
/
user.go
40 lines (34 loc) · 945 Bytes
/
user.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
package buildkite
import (
"context"
)
// UserService handles communication with the user related
// methods of the buildkite API.
//
// buildkite API docs: https://buildkite.com/docs/api
type UserService struct {
client *Client
}
// User represents a buildkite user.
type User struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
}
// CurrentUser returns the user associated with the access token being used
//
// buildkite API docs: https://buildkite.com/docs/api
func (us *UserService) CurrentUser(ctx context.Context) (User, *Response, error) {
u := "v2/user"
req, err := us.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return User{}, nil, err
}
var user User
resp, err := us.client.Do(req, &user)
if err != nil {
return User{}, resp, err
}
return user, resp, err
}