Add ability to use 'me' in place of user id for APIv4 (#5826)

Этот коммит содержится в:
Joram Wilander
2017-03-21 18:43:16 -04:00
коммит произвёл GitHub
родитель fd6e2f3f73
Коммит bea49cbcf3
4 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

@@ -349,6 +349,16 @@ func (c *Client4) CreateUser(user *User) (*User, *Response) {
}
}
// GetMe returns the logged in user.
func (c *Client4) GetMe(etag string) (*User, *Response) {
if r, err := c.DoApiGet(c.GetUserRoute(ME), etag); err != nil {
return nil, &Response{StatusCode: r.StatusCode, Error: err}
} else {
defer closeBody(r)
return UserFromJson(r.Body), BuildResponse(r)
}
}
// GetUser returns a user based on the provided user id string.
func (c *Client4) GetUser(userId, etag string) (*User, *Response) {
if r, err := c.DoApiGet(c.GetUserRoute(userId), etag); err != nil {

Просмотреть файл

@@ -17,6 +17,7 @@ import (
)
const (
ME = "me"
USER_NOTIFY_ALL = "all"
USER_NOTIFY_MENTION = "mention"
USER_NOTIFY_NONE = "none"