diff options
author | Joram Wilander <jwawilander@gmail.com> | 2018-01-24 08:50:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-24 08:50:11 -0500 |
commit | 3918ed6c589a19bd385a6e566f07dc14d7484c49 (patch) | |
tree | f4a827a00e50eab1d47a70a6a85d369c44c84940 /model/client4.go | |
parent | f2415b98f652bc695d3825e54ac832ee468c0a63 (diff) | |
download | chat-3918ed6c589a19bd385a6e566f07dc14d7484c49.tar.gz chat-3918ed6c589a19bd385a6e566f07dc14d7484c49.tar.bz2 chat-3918ed6c589a19bd385a6e566f07dc14d7484c49.zip |
Add GET /emojis/name/{emoji_name} API endpoint (#8142)
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/model/client4.go b/model/client4.go index 151b5a491..0694ecbdf 100644 --- a/model/client4.go +++ b/model/client4.go @@ -282,6 +282,10 @@ func (c *Client4) GetEmojiRoute(emojiId string) string { return fmt.Sprintf(c.GetEmojisRoute()+"/%v", emojiId) } +func (c *Client4) GetEmojiByNameRoute(name string) string { + return fmt.Sprintf(c.GetEmojisRoute()+"/name/%v", name) +} + func (c *Client4) GetReactionsRoute() string { return fmt.Sprintf("/reactions") } @@ -3045,7 +3049,7 @@ func (c *Client4) DeleteEmoji(emojiId string) (bool, *Response) { } } -// GetEmoji returns a custom emoji in the system on the provided emoji id string. +// GetEmoji returns a custom emoji based on the emojiId string. func (c *Client4) GetEmoji(emojiId string) (*Emoji, *Response) { if r, err := c.DoApiGet(c.GetEmojiRoute(emojiId), ""); err != nil { return nil, BuildErrorResponse(r, err) @@ -3055,6 +3059,16 @@ func (c *Client4) GetEmoji(emojiId string) (*Emoji, *Response) { } } +// GetEmojiByName returns a custom emoji based on the name string. +func (c *Client4) GetEmojiByName(name string) (*Emoji, *Response) { + if r, err := c.DoApiGet(c.GetEmojiByNameRoute(name), ""); err != nil { + return nil, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return EmojiFromJson(r.Body), BuildResponse(r) + } +} + // GetEmojiImage returns the emoji image. func (c *Client4) GetEmojiImage(emojiId string) ([]byte, *Response) { if r, err := c.DoApiGet(c.GetEmojiRoute(emojiId)+"/image", ""); err != nil { |