22
33namespace FiveamCode \LaravelNotionApi \Endpoints ;
44
5- use FiveamCode \LaravelNotionApi \Entities \Collections \BlockCollection ;
65use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
76use FiveamCode \LaravelNotionApi \Notion ;
8- use Illuminate \Support \Collection ;
7+ use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
8+ use FiveamCode \LaravelNotionApi \Entities \Collections \BlockCollection ;
99
1010class Block extends Endpoint
1111{
@@ -24,39 +24,17 @@ public function __construct(Notion $notion, string $blockId)
2424 *
2525 * @return BlockCollection
2626 */
27- public function children (): Collection
28- {
29- return $ this ->collectChildren ()->getResults ();
30- }
31-
32- /**
33- * Retrieve block children (as raw json-data)
34- * url: https://api.notion.com/{version}/blocks/{block_id}/children
35- * notion-api-docs: https://developers.notion.com/reference/get-block-children
36- *
37- * @return array
38- */
39- public function childrenRaw (): array
40- {
41- return $ this ->collectChildren ()->getRawResults ();
42- }
43-
44- private function collectChildren (): BlockCollection
27+ public function children (): BlockCollection
4528 {
4629 $ response = $ this ->get (
4730 $ this ->url (Endpoint::BLOCKS . "/ " . $ this ->blockId . "/children " . "? {$ this ->buildPaginationQuery ()}" )
4831 );
49- if (!$ response ->ok ())
50- throw HandlingException::instance ("Block not found. " , ["blockId " => $ this ->blockId ]);
51-
5232
53- $ blockCollection = new BlockCollection ($ response ->json ());
54- return $ blockCollection ;
33+ return new BlockCollection ($ response ->json ());
5534 }
5635
5736 public function create (): array
5837 {
59- //toDo
60- throw new \Exception ("not implemented yet " );
38+ throw new HandlingException ("Not implemented " );
6139 }
6240}
0 commit comments