mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-13 20:16:30 +00:00
25 lines
482 B
Go
25 lines
482 B
Go
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
|
|
}
|