From 80684ad69f641bb759095beff0e1a15db0aa33b1 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Mon, 17 Apr 2017 16:07:28 +0200 Subject: implement DELETE /emoji/{emoji_id} fro apiV4 (#6021) implement GET /emoji/{emoji_id} for apiv4 --- model/client4.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index 6281b3df4..9fda40aca 100644 --- a/model/client4.go +++ b/model/client4.go @@ -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. -- cgit v1.2.3-1-g7c22