-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuser.go
More file actions
26 lines (23 loc) · 757 Bytes
/
user.go
File metadata and controls
26 lines (23 loc) · 757 Bytes
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
package wallabago
import "encoding/json"
// LoggedInUser represents the object being returned from the API request /user
type LoggedInUser struct {
ID int `json:"id"`
UserName string `json:"username"`
Email string `json:"email"`
CreatedAt *WallabagTime `json:"created_at"`
UpdatedAt *WallabagTime `json:"updated_at"`
}
// User returns the user info of the logged in user of the configured wallabag instance
func User(bodyByteGetterFunc BodyByteGetter) (LoggedInUser, error) {
var u LoggedInUser
userJSONByte, err := bodyByteGetterFunc(LibConfig.WallabagURL+"/api/user", "GET", nil)
if err != nil {
return u, err
}
err = json.Unmarshal(userJSONByte, &u)
if err != nil {
return u, err
}
return u, err
}