implement DELETE /emoji/{emoji_id} fro apiV4 (#6021)

implement GET /emoji/{emoji_id} for apiv4
Этот коммит содержится в:
Carlos Tadeu Panato Junior
2017-04-17 16:07:28 +02:00
коммит произвёл Harrison Healey
родитель 62974f19cd
Коммит 80684ad69f
6 изменённых файлов: 248 добавлений и 30 удалений

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

@@ -234,6 +234,10 @@ func (c *Client4) GetEmojisRoute() string {
return fmt.Sprintf("/emoji")
}
func (c *Client4) GetEmojiRoute(emojiId string) string {
return fmt.Sprintf(c.GetEmojisRoute()+"/%v", emojiId)
}
func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) {
return c.DoApiRequest(http.MethodGet, url, "", etag)
}
@@ -2335,6 +2339,26 @@ func (c *Client4) GetEmojiList() ([]*Emoji, *Response) {
}
}
// DeleteEmoji delete an custom emoji on the provided emoji id string.
func (c *Client4) DeleteEmoji(emojiId string) (bool, *Response) {
if r, err := c.DoApiDelete(c.GetEmojiRoute(emojiId)); err != nil {
return false, &Response{StatusCode: r.StatusCode, Error: err}
} else {
defer closeBody(r)
return CheckStatusOK(r), BuildResponse(r)
}
}
// GetEmoji returns a custom emoji in the system on the provided emoji id string.
func (c *Client4) GetEmoji(emojiId string) (*Emoji, *Response) {
if r, err := c.DoApiGet(c.GetEmojiRoute(emojiId), ""); err != nil {
return nil, &Response{StatusCode: r.StatusCode, Error: err}
} else {
defer closeBody(r)
return EmojiFromJson(r.Body), BuildResponse(r)
}
}
// Reaction Section
// GetReactions returns a list of reactions to a post.