forked from forgejo/forgejo
code.gitea.io/sdk/gitea v0.14.0 -> v0.15.1 (#18186)
This commit is contained in:
parent
8760af752a
commit
ec6cc38c6c
29 changed files with 695 additions and 133 deletions
50
vendor/code.gitea.io/sdk/gitea/user.go
generated
vendored
50
vendor/code.gitea.io/sdk/gitea/user.go
generated
vendored
|
@ -6,6 +6,8 @@ package gitea
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -23,9 +25,30 @@ type User struct {
|
|||
// User locale
|
||||
Language string `json:"language"`
|
||||
// Is the user an administrator
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
LastLogin time.Time `json:"last_login,omitempty"`
|
||||
Created time.Time `json:"created,omitempty"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
// Date and Time of last login
|
||||
LastLogin time.Time `json:"last_login"`
|
||||
// Date and Time of user creation
|
||||
Created time.Time `json:"created"`
|
||||
// Is user restricted
|
||||
Restricted bool `json:"restricted"`
|
||||
// Is user active
|
||||
IsActive bool `json:"active"`
|
||||
// Is user login prohibited
|
||||
ProhibitLogin bool `json:"prohibit_login"`
|
||||
// the user's location
|
||||
Location string `json:"location"`
|
||||
// the user's website
|
||||
Website string `json:"website"`
|
||||
// the user's description
|
||||
Description string `json:"description"`
|
||||
// User visibility level option
|
||||
Visibility VisibleType `json:"visibility"`
|
||||
|
||||
// user counts
|
||||
FollowerCount int `json:"followers_count"`
|
||||
FollowingCount int `json:"following_count"`
|
||||
StarredRepoCount int `json:"starred_repos_count"`
|
||||
}
|
||||
|
||||
// GetUserInfo get user info by user's name
|
||||
|
@ -44,3 +67,24 @@ func (c *Client) GetMyUserInfo() (*User, *Response, error) {
|
|||
resp, err := c.getParsedResponse("GET", "/user", nil, nil, u)
|
||||
return u, resp, err
|
||||
}
|
||||
|
||||
// GetUserByID returns user by a given user ID
|
||||
func (c *Client) GetUserByID(id int64) (*User, *Response, error) {
|
||||
if id < 0 {
|
||||
return nil, nil, fmt.Errorf("invalid user id %d", id)
|
||||
}
|
||||
|
||||
query := make(url.Values)
|
||||
query.Add("uid", strconv.FormatInt(id, 10))
|
||||
users, resp, err := c.searchUsers(query.Encode())
|
||||
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
if len(users) == 1 {
|
||||
return users[0], resp, err
|
||||
}
|
||||
|
||||
return nil, resp, fmt.Errorf("user not found with id %d", id)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue