Skip to content

Commit 4b847e1

Browse files
committed
add alias for Comment Entity
- to avoid missunderstanding - add phpdocs for `create()`
1 parent 2533e4b commit 4b847e1

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Endpoints/Comments.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace FiveamCode\LaravelNotionApi\Endpoints;
44

55
use FiveamCode\LaravelNotionApi\Entities\Collections\CommentCollection;
6-
use FiveamCode\LaravelNotionApi\Entities\Comment;
6+
use FiveamCode\LaravelNotionApi\Entities\Comment as CommentEntity;
77
use FiveamCode\LaravelNotionApi\Exceptions\HandlingException;
88
use FiveamCode\LaravelNotionApi\Exceptions\NotionException;
99
use 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

Comments
 (0)