notion-sdk-php icon indicating copy to clipboard operation
notion-sdk-php copied to clipboard

Improve CreateEmpty method for Page Properties

Open ren0v opened this issue 2 years ago • 1 comments

Some Page Properties (Date, Email, Number, PhoneNumber, RichTextProperty, Select, Url) have a CreateEmpty method but other editable properties (Checkbox, Files, Multiselect, People, Relation, Status, Title) don't have such a method.

This PR is about

  • Adding the missing createEmpty() method to all editable properties.
  • Improving the createEmpty() method by allowing to pass the id of the property so that we can have a fresh empty property set with the right id.

ren0v avatar Feb 08 '24 08:02 ren0v

What is the use case for createEmpty() with IDs? Is it to remove the data from a property? If yes, I think it would be better to have a new method, maybe clear()?

Not really removing the data from a property.

I'm running an app that sync some Notion databases with the app and the other way around. For that, I rely on the ids of the Notion database properties as the enduser can change the name of the property on Notion. When the enduser makes an update on the app, I need to sync the update on Notion. For that, I create a new empty property with the SDK and I need to set the right id (that is saved on the app database), then I use a changeXXX method to add the new content and then run the update request with the API.

ren0v avatar Feb 23 '24 08:02 ren0v