diff options
author | Andrei Stanciu <andrei.stanciu@geminisols.ro> | 2017-02-28 11:34:32 +0200 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-02-28 09:34:32 +0000 |
commit | 6ff350380b209266282cff32872f94bb9cd31d57 (patch) | |
tree | 916390cf6af4358b599a67de4897bd68f100f432 /model | |
parent | 76fa840b52ea79f05e5e681abca92b279de78182 (diff) | |
download | chat-6ff350380b209266282cff32872f94bb9cd31d57.tar.gz chat-6ff350380b209266282cff32872f94bb9cd31d57.tar.bz2 chat-6ff350380b209266282cff32872f94bb9cd31d57.zip |
ApiV4: PUT /posts/{post_id} (#5521)
Diffstat (limited to 'model')
-rw-r--r-- | model/client4.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index cbaf8234b..e6c9192b9 100644 --- a/model/client4.go +++ b/model/client4.go @@ -731,6 +731,16 @@ func (c *Client4) CreatePost(post *Post) (*Post, *Response) { } } +// UpdatePost updates a post based on the provided post struct. +func (c *Client4) UpdatePost(postId string, post *Post) (*Post, *Response) { + if r, err := c.DoApiPut(c.GetPostRoute(postId), post.ToJson()); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return PostFromJson(r.Body), BuildResponse(r) + } +} + // GetPost gets a single post. func (c *Client4) GetPost(postId string, etag string) (*Post, *Response) { if r, err := c.DoApiGet(c.GetPostRoute(postId), etag); err != nil { |