diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2016-12-28 14:44:32 +0100 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2016-12-28 10:44:32 -0300 |
commit | 5fd11bd674075c57cb5c6f9e4b90042c1a37b3b5 (patch) | |
tree | 25fb7c5adfa7465b235936fac7aa4293ce7e2e79 /model/client.go | |
parent | 14f1f4e9b119f00246a7a5f49e607413c99e4f74 (diff) | |
download | chat-5fd11bd674075c57cb5c6f9e4b90042c1a37b3b5.tar.gz chat-5fd11bd674075c57cb5c6f9e4b90042c1a37b3b5.tar.bz2 chat-5fd11bd674075c57cb5c6f9e4b90042c1a37b3b5.zip |
Add API call to get a user by their email address (#4884)
* Add API call to get a user by their email address
* update per review
Diffstat (limited to 'model/client.go')
-rw-r--r-- | model/client.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/model/client.go b/model/client.go index 4a6cb169f..54095fcba 100644 --- a/model/client.go +++ b/model/client.go @@ -518,6 +518,21 @@ func (c *Client) GetByUsername(username string, etag string) (*Result, *AppError } } +// getByEmail returns a user based on a provided username string. Must be authenticated. +func (c *Client) GetByEmail(email string, etag string) (*User, *ResponseMetadata) { + if r, err := c.DoApiGet(fmt.Sprintf("/users/email/%v", email), "", etag); err != nil { + return nil, &ResponseMetadata{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return UserFromJson(r.Body), + &ResponseMetadata{ + StatusCode: r.StatusCode, + RequestId: r.Header.Get(HEADER_REQUEST_ID), + Etag: r.Header.Get(HEADER_ETAG_SERVER), + } + } +} + // GetMe returns the current user. func (c *Client) GetMe(etag string) (*Result, *AppError) { if r, err := c.DoApiGet("/users/me", "", etag); err != nil { |