1
0
mirror of https://github.com/writeas/go-writeas.git synced 2025-07-27 19:59:02 +00:00

Support publishing posts to a collection

This commit is contained in:
Matt Baer 2017-11-12 05:08:01 -05:00
parent 8425a91fe1
commit 71e8a2f11a

View File

@ -47,6 +47,9 @@ type (
Language *string `json:"lang,omitempty"` Language *string `json:"lang,omitempty"`
Crosspost []map[string]string `json:"crosspost,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 // 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. // up. See https://developer.write.as/docs/api/#publish-a-post.
func (c *Client) CreatePost(sp *PostParams) (*Post, error) { func (c *Client) CreatePost(sp *PostParams) (*Post, error) {
p := &Post{} 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 { if err != nil {
return nil, err return nil, err
} }