From 539b5997bb53c87b9074f2625a8e9f9bbc7b61c9 Mon Sep 17 00:00:00 2001 From: JohGuentner <3506359+johguentner@users.noreply.github.com> Date: Sun, 18 Jul 2021 11:21:18 +0200 Subject: [PATCH 1/2] add url to page - url is now retreived in the endpoint "->pages()->find($pageId)" - url can now be read by the user in a straightforward way [added to notion-api at 2021-07-02] [https://developers.notion.com/changelog/page-objects-now-return-url] --- src/Entities/Page.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Entities/Page.php b/src/Entities/Page.php index d0aa80e..c4ed7cb 100644 --- a/src/Entities/Page.php +++ b/src/Entities/Page.php @@ -31,6 +31,11 @@ class Page extends Entity */ protected string $title = ''; + /** + * @var string + */ + protected string $url = ''; + /** * @var string */ @@ -101,6 +106,7 @@ private function fillFromRaw(): void $this->fillObjectType(); $this->fillProperties(); $this->fillTitle(); // This has to be called after fillProperties(), since title is provided by properties + $this->fillUrl(); $this->fillCreatedTime(); $this->fillLastEditedTime(); } @@ -151,6 +157,16 @@ private function fillTitle(): void } } + /** + * + */ + private function fillUrl(): void + { + if (Arr::exists($this->responseData, 'url')) { + $this->url = $this->responseData['url']; + } + } + /** * @param $propertyTitle * @param $property @@ -324,6 +340,14 @@ public function getTitle(): string return $this->title; } + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + /** * @return Collection */ From 27f61a688d18c6c07136203aa59f95e8687083c4 Mon Sep 17 00:00:00 2001 From: JohGuentner <3506359+johguentner@users.noreply.github.com> Date: Sat, 21 Aug 2021 20:28:29 +0200 Subject: [PATCH 2/2] rename 'fillUrl' to 'fillPageUrl' - small refactoring was necessary to clarify, that this 'filling' represents the actual page-url of the notion-page and is not a fillable property of a page --- src/Entities/Page.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entities/Page.php b/src/Entities/Page.php index c4ed7cb..9626e0e 100644 --- a/src/Entities/Page.php +++ b/src/Entities/Page.php @@ -106,7 +106,7 @@ private function fillFromRaw(): void $this->fillObjectType(); $this->fillProperties(); $this->fillTitle(); // This has to be called after fillProperties(), since title is provided by properties - $this->fillUrl(); + $this->fillPageUrl(); $this->fillCreatedTime(); $this->fillLastEditedTime(); } @@ -160,7 +160,7 @@ private function fillTitle(): void /** * */ - private function fillUrl(): void + private function fillPageUrl(): void { if (Arr::exists($this->responseData, 'url')) { $this->url = $this->responseData['url'];