forked from contentful-labs/contentful-go
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathuser.go
39 lines (32 loc) · 999 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
package contentful
import (
"fmt"
)
// UsersService service
type UsersService service
// User model
type User struct {
Sys *Sys `json:"sys,omitempty"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
AvatarURL string `json:"avatarUrl"`
Email string `json:"email"`
Activated bool `json:"activated"`
SignInCount int `json:"signInCount"`
Confirmed bool `json:"confirmed"`
TwoFactorAuthenticationEnabled bool `json:"2faEnabled"`
}
// Me returns current authenticated user
func (service *UsersService) Me() (*User, error) {
path := fmt.Sprintf("/users/me")
method := "GET"
req, err := service.c.newRequest(method, path, nil, nil)
if err != nil {
return nil, err
}
var user User
if err := service.c.do(req, &user); err != nil {
return nil, err
}
return &user, nil
}