woodpecker/remote/coding/internal/user.go

26 lines
482 B
Go
Raw Normal View History

2017-07-22 09:12:09 +00:00
package internal
import (
"encoding/json"
)
type User struct {
GlobalKey string `json:"global_key"`
Email string `json:"email"`
Avatar string `json:"avatar"`
}
func (c *Client) GetCurrentUser() (*User, error) {
u := "/account/current_user"
resp, err := c.Get(u, nil)
if err != nil {
return nil, err
}
user := &User{}
err = json.Unmarshal(resp, user)
if err != nil {
return nil, APIClientErr{"fail to parse current user data", u, err}
}
return user, nil
}