Implement GET /users/username/{username} endpoint for APIv4 (#5310)
* added get user by username endpoint * added get user by username unit test and driver * changed username length to 22 characters max * changed Params to UserName to Username * reorganized get user by username and get user by email formatting in model/client4
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
5462f0119e
Коммит
0162d8ad08
@@ -56,6 +56,10 @@ func (c *Client4) GetUserRoute(userId string) string {
|
||||
return fmt.Sprintf(c.GetUsersRoute()+"/%v", userId)
|
||||
}
|
||||
|
||||
func (c *Client4) GetUserByUsernameRoute(userName string) string {
|
||||
return fmt.Sprintf(c.GetUsersRoute()+"/username/%v", userName)
|
||||
}
|
||||
|
||||
func (c *Client4) GetUserByEmailRoute(email string) string {
|
||||
return fmt.Sprintf(c.GetUsersRoute()+"/email/%v", email)
|
||||
}
|
||||
@@ -226,6 +230,16 @@ func (c *Client4) GetUser(userId, etag string) (*User, *Response) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetUserByUsername returns a user based on the provided user name string.
|
||||
func (c *Client4) GetUserByUsername(userName, etag string) (*User, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetUserByUsernameRoute(userName), etag); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return UserFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// GetUserByEmail returns a user based on the provided user email string.
|
||||
func (c *Client4) GetUserByEmail(email, etag string) (*User, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetUserByEmailRoute(email), etag); err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user