Skip to content

Commit 69b1563

Browse files
committed
page-creation with page as parent (createInPage)
1 parent e2577e1 commit 69b1563

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Endpoints/Pages.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,33 @@ public function createInDatabase(string $parentId, Page $page): Page
5858
return new Page($response);
5959
}
6060

61+
/**
62+
* @return Page
63+
*/
64+
public function createInPage(string $parentId, Page $page): Page
65+
{
66+
$postData = [];
67+
$properties = [];
68+
69+
foreach ($page->getProperties() as $property) {
70+
$properties[$property->getTitle()] = $property->getRawContent();
71+
}
72+
73+
$postData["parent"] = ["page_id" => $parentId];
74+
$postData["properties"] = $properties;
75+
76+
77+
$response = $this
78+
->post(
79+
$this->url(Endpoint::PAGES),
80+
$postData
81+
)
82+
->json();
83+
84+
return new Page($response);
85+
}
86+
87+
6188

6289
/**
6390
* @return array

0 commit comments

Comments
 (0)