From d2b86f1b8de4784baf578b611cf80779ccfa722a Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Wed, 19 Apr 2017 05:15:15 +0900 Subject: APIv4 POST /reactions (#6092) * APIv4 POST /reactions * update corresponding V3 endpoint --- model/client4.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'model') diff --git a/model/client4.go b/model/client4.go index ad3ff51a4..a7a3607e6 100644 --- a/model/client4.go +++ b/model/client4.go @@ -238,6 +238,10 @@ func (c *Client4) GetEmojiRoute(emojiId string) string { return fmt.Sprintf(c.GetEmojisRoute()+"/%v", emojiId) } +func (c *Client4) GetReactionsRoute() string { + return fmt.Sprintf("/reactions") +} + func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) { return c.DoApiRequest(http.MethodGet, url, "", etag) } @@ -2374,6 +2378,16 @@ func (c *Client4) GetEmoji(emojiId string) (*Emoji, *Response) { // Reaction Section +// SaveReaction saves an emoji reaction for a post. Returns the saved reaction if successful, otherwise an error will be returned. +func (c *Client4) SaveReaction(reaction *Reaction) (*Reaction, *Response) { + if r, err := c.DoApiPost(c.GetReactionsRoute(), reaction.ToJson()); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return ReactionFromJson(r.Body), BuildResponse(r) + } +} + // GetReactions returns a list of reactions to a post. func (c *Client4) GetReactions(postId string) ([]*Reaction, *Response) { if r, err := c.DoApiGet(c.GetPostRoute(postId)+"/reactions", ""); err != nil { -- cgit v1.2.3-1-g7c22