Add GET /emojis/name/{emoji_name} API endpoint (#8142)

This commit is contained in:
Joram Wilander
2018-01-24 08:50:11 -05:00
committed by GitHub
parent f2415b98f6
commit 3918ed6c58
6 changed files with 82 additions and 3 deletions

View File

@@ -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 {