From 71e8a2f11afe378255b62ea2cd59dc5d1688b9a5 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sun, 12 Nov 2017 05:08:01 -0500 Subject: [PATCH] Support publishing posts to a collection --- post.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/post.go b/post.go index f0f214c..a45b914 100644 --- a/post.go +++ b/post.go @@ -47,6 +47,9 @@ type ( Language *string `json:"lang,omitempty"` Crosspost []map[string]string `json:"crosspost,omitempty"` + + // Parameters for collection posts + Collection string `json:"-"` } // ClaimPostResult contains the post-specific result for a request to @@ -89,7 +92,11 @@ func (c *Client) GetPost(id string) (*Post, error) { // up. See https://developer.write.as/docs/api/#publish-a-post. func (c *Client) CreatePost(sp *PostParams) (*Post, error) { p := &Post{} - env, err := c.post("/posts", sp, p) + endPre := "" + if sp.Collection != "" { + endPre = "/collections/" + sp.Collection + } + env, err := c.post(endPre+"/posts", sp, p) if err != nil { return nil, err }