From 8a54ab8441589d3e6e9e8db7bd355771140e8712 Mon Sep 17 00:00:00 2001 From: Micah Date: Mon, 26 Feb 2024 20:18:38 -0500 Subject: [PATCH] Document Post.update() and add it to README --- README.md | 14 ++++++++++++-- lib.js | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a23231d..d7ce355 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ const cohost = require("cohost"); let [project] = await user.getProjects(); // Create Post - await cohost.Post.create(project, { + let myPostID = await cohost.Post.create(project, { postState: 1, headline: "hello world from cohost.js", adultContent: false, @@ -31,6 +31,16 @@ const cohost = require("cohost"); tags: [] }); + // Edit Post + await cohost.Post.update(project, myPostID, { + postState: 1, + headline: "Hello world from cohost.js!", + adultContent: false, + blocks: [], + cws: [], + tags: ["cohost.js"] + }); + // Get Posts of Project let posts = await project.getPosts(); @@ -64,10 +74,10 @@ Works: - Logging in - Getting the posts of a project - Creating a post +- Editing a post Doesn't work: -- Editing a post: possible, haven't done it - Sharing a post: possible, haven't done it - Liking a post: possible, haven't done it - Getting notifications: possible, haven't done it diff --git a/lib.js b/lib.js index a61bfdc..f2cae43 100644 --- a/lib.js +++ b/lib.js @@ -265,7 +265,12 @@ class Post { return postId; } - /** see {@link create} */ + /** + * + * @param {Project} project Project to post to + * @param {string} postId ID of the post to update + * @param {PostCreate} data + */ static async update(project, postId, data) { await fetch( "PUT",