Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Commit 1fefcbc

Browse files
Added logic for updating page properties
1 parent f35d1c9 commit 1fefcbc

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/Notion/Http/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public function post(string $url, array $options = []): Response
5151
return $this->makeCall($url, 'post', $options);
5252
}
5353

54+
public function patch(string $url, array $options = []): Response
55+
{
56+
return $this->makeCall($url, 'patch', $options);
57+
}
58+
5459
public function get(string $url, array $options = []): Response
5560
{
5661
return $this->makeCall($url, 'get', $options);

src/Notion/Objects/Page.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ public function save()
9393
'body' => json_encode($this->prepareForRequest()),
9494
];
9595

96-
if ($this->context === 'create') {
96+
if (!$this->id) {
9797
return $this->notion->getClient()->post('pages', $options);
9898
}
99+
100+
return $this->notion->getClient()->patch('pages/' . $this->id, $options);
99101
}
100102

101103
public function setContext($context): self

src/Notion/Properties/Select.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public function value()
1212
public function set($value): void
1313
{
1414
$this->config->select->name = $value;
15+
unset($this->config->select->id, $this->config->select->color);
1516
}
1617

1718
public function getValue()

0 commit comments

Comments
 (0)