-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
59 lines (54 loc) · 1.45 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package dribbble
import (
"encoding/json"
"time"
)
// User client
type User struct {
*Client
}
// UserOut response structure
type UserOut struct {
ID int `json:"id"`
Name string `json:"name"`
Login string `json:"login"`
HTMLURL string `json:"html_url"`
AvatarURL string `json:"avatar_url"`
Bio string `json:"bio"`
Location string `json:"location"`
Links struct {
Web string `json:"web"`
Twitter string `json:"twitter"`
} `json:"links"`
CanUploadShot bool `json:"can_upload_shot"`
Pro bool `json:"pro"`
FollowersCount int `json:"followers_count"`
CreatedAt time.Time `json:"created_at"`
Type string `json:"type"`
Teams []struct {
ID int `json:"id"`
Name string `json:"name"`
Login string `json:"login"`
HTMLURL string `json:"html_url"`
AvatarURL string `json:"avatar_url"`
Bio string `json:"bio"`
Location string `json:"location"`
Links struct {
Web string `json:"web"`
Twitter string `json:"twitter"`
} `json:"links"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
} `json:"teams"`
}
// GetUser which is currenlty logged in
func (c *User) GetUser() (out *UserOut, err error) {
body, err := c.call("GET", "/user", nil)
if err != nil {
return nil, err
}
defer body.Close()
err = json.NewDecoder(body).Decode(&out)
return
}