From 5d56fbb036cc7044eae639c92836e0b14ffe7dab Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Fri, 31 Mar 2017 22:58:47 +0900 Subject: APIv4 POST /posts/{post_id/pin & unpin (#5906) * APIv4 get /posts/{post_id}/pin & unpin * remove PinnedPost from api test helper --- model/client4.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index a43950a68..e62ce57bd 100644 --- a/model/client4.go +++ b/model/client4.go @@ -1249,6 +1249,26 @@ func (c *Client4) PatchPost(postId string, patch *PostPatch) (*Post, *Response) } } +// PinPost pin a post based on provided post id string. +func (c *Client4) PinPost(postId string) (bool, *Response) { + if r, err := c.DoApiPost(c.GetPostRoute(postId)+"/pin", ""); err != nil { + return false, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return CheckStatusOK(r), BuildResponse(r) + } +} + +// UnpinPost unpin a post based on provided post id string. +func (c *Client4) UnpinPost(postId string) (bool, *Response) { + if r, err := c.DoApiPost(c.GetPostRoute(postId)+"/unpin", ""); err != nil { + return false, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return CheckStatusOK(r), 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 { -- cgit v1.2.3-1-g7c22