diff options
author | Ruzette Tanyag <ruzette@users.noreply.github.com> | 2017-02-07 11:54:07 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-02-07 11:54:07 -0500 |
commit | d91fea65188a51dd41976cad47f9c8ebacd75a04 (patch) | |
tree | 792f8563d04957c1ddf56a731821051c8466eba7 /model | |
parent | 5cc30fa06149e1291deed6f53de53ecf25600d2c (diff) | |
download | chat-d91fea65188a51dd41976cad47f9c8ebacd75a04.tar.gz chat-d91fea65188a51dd41976cad47f9c8ebacd75a04.tar.bz2 chat-d91fea65188a51dd41976cad47f9c8ebacd75a04.zip |
Implement GET `/users/email/{email}` endpoint for APIv4 (#5309)
* added get user by email endpoint for APIv4
* added get user by email endpoint unit test and driver
* removed the appended return of user ids on logout
* Added RequireEmail to validate user email. Also updated the get user by email endpoint and unit test
Diffstat (limited to 'model')
-rw-r--r-- | model/client4.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index 1bdb7e55e..42b96a730 100644 --- a/model/client4.go +++ b/model/client4.go @@ -56,6 +56,10 @@ func (c *Client4) GetUserRoute(userId string) string { return fmt.Sprintf(c.GetUsersRoute()+"/%v", userId) } +func (c *Client4) GetUserByEmailRoute(email string) string { + return fmt.Sprintf(c.GetUsersRoute()+"/email/%v", email) +} + func (c *Client4) GetTeamsRoute() string { return fmt.Sprintf("/teams") } @@ -210,6 +214,16 @@ func (c *Client4) GetUser(userId, etag string) (*User, *Response) { } } +// 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 { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return UserFromJson(r.Body), BuildResponse(r) + } +} + // GetUsers returns a page of users on the system. Page counting starts at 0. func (c *Client4) GetUsers(page int, perPage int, etag string) ([]*User, *Response) { query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) |