@@ -54,7 +54,7 @@ public function retrieve(): BlockEntity
5454
5555 /**
5656 * Retrieve block children
57- * url: https://api.notion.com/{version}/blocks/{block_id}/children
57+ * url: https://api.notion.com/{version}/blocks/{block_id}/children [get]
5858 * notion-api-docs: https://developers.notion.com/reference/get-block-children
5959 *
6060 * @return BlockCollection
@@ -71,11 +71,37 @@ public function children(): BlockCollection
7171 }
7272
7373 /**
74- * @return array
74+ * Append one Block or an array of Blocks
75+ * url: https://api.notion.com/{version}/blocks/{block_id}/children [patch]
76+ * notion-api-docs: https://developers.notion.com/reference/patch-block-children
77+ *
78+ * @return FiveamCode\LaravelNotionApi\Entities\Blocks\Block
7579 * @throws HandlingException
7680 */
77- public function create ( ): array
81+ public function append ( array | BlockEntity $ appendices ): BlockEntity
7882 {
79- throw new HandlingException ('Not implemented ' );
83+ if (!is_array ($ appendices )) {
84+ $ appendices = [$ appendices ];
85+ }
86+ $ children = [];
87+
88+ foreach ($ appendices as $ block ) {
89+ $ children [] = [
90+ "object " => "block " ,
91+ "type " => $ block ->getType (),
92+ $ block ->getType () => $ block ->getRawContent ()
93+ ];
94+ }
95+
96+ $ body = [
97+ "children " => $ children
98+ ];
99+
100+ $ response = $ this ->patch (
101+ $ this ->url (Endpoint::BLOCKS . '/ ' . $ this ->blockId . '/children ' . "" ),
102+ $ body
103+ );
104+
105+ return new BlockEntity ($ response ->json ());
80106 }
81107}
0 commit comments