33namespace FiveamCode \LaravelNotionApi \Endpoints ;
44
55use FiveamCode \LaravelNotionApi \Entities \Collections \CommentCollection ;
6- use FiveamCode \LaravelNotionApi \Entities \Comment ;
6+ use FiveamCode \LaravelNotionApi \Entities \Comment as CommentEntity ;
77use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
88use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
99use FiveamCode \LaravelNotionApi \Notion ;
@@ -38,9 +38,10 @@ public function __construct(Notion $notion)
3838 }
3939
4040 /**
41- * Retrieve block children
41+ * Retrieve a list of comments
4242 * url: https://api.notion.com/{version}/comments?block_id=* [get]
4343 * notion-api-docs: https://developers.notion.com/reference/retrieve-a-comment.
44+ * @param string $blockId
4445 *
4546 * @return CommentCollection
4647 *
@@ -50,7 +51,7 @@ public function __construct(Notion $notion)
5051 public function ofBlock (string $ blockId ): CommentCollection
5152 {
5253 $ response = $ this ->get (
53- $ this ->url (Endpoint::COMMENTS . "?block_id= {$ blockId }& {$ this ->buildPaginationQuery ()}" )
54+ $ this ->url (Endpoint::COMMENTS . "?block_id= {$ blockId }& {$ this ->buildPaginationQuery ()}" )
5455 );
5556
5657 return new CommentCollection ($ response ->json ());
@@ -86,7 +87,18 @@ public function onPage(string $pageId): self
8687 return $ this ;
8788 }
8889
89- public function create ($ comment ): Comment
90+ /**
91+ * Create a comment
92+ * url: https://api.notion.com/{version}/comments [post]
93+ * notion-api-docs: https://developers.notion.com/reference/create-a-comment.
94+ * @param CommentEntity $comment
95+ *
96+ * @return CommentEntity
97+ *
98+ * @throws HandlingException
99+ * @throws NotionException
100+ */
101+ public function create ($ comment ): CommentEntity
90102 {
91103 if ($ this ->discussionId === null && $ this ->pageId === null ) {
92104 throw new HandlingException ('You must use `onDiscussion()` or `onPage()`. ' );
@@ -106,6 +118,6 @@ public function create($comment): Comment
106118 $ body
107119 );
108120
109- return new Comment ($ response ->json ());
121+ return new CommentEntity ($ response ->json ());
110122 }
111123}
0 commit comments