diff --git a/README.md b/README.md index 0de9f65..c5a829e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ _*does not use notion-sdk-py client_ Create new integration and get your Notion API Token at notion.so -> [here](https://www.notion.com/my-integrations) -Invite your new integration 'manager' to your Notion workspace or particular pages. +Invite your new integration 'manager' to your pages or databases. `from pytion import Notion; no = Notion(token=SOME_TOKEN)` @@ -89,6 +89,8 @@ There are user classmethods for models: `RichTextArray.create()`, `Property.create()`, `PropertyValue.create()`, `Database.create()`, `Page.create()`, `Block.create()`, `LinkTo.create()`, `User.create()` +And every model has a `.get()` method that returns API friendly JSON. + ### Supported block types At present the API only supports the block types which are listed in the reference below. Any unsupported block types will continue to appear in the structure, but only contain a `type` set to `"unsupported"`. diff --git a/pytion/api.py b/pytion/api.py index e28f108..f8f6a6c 100644 --- a/pytion/api.py +++ b/pytion/api.py @@ -291,7 +291,7 @@ def db_create( """ :param database_obj: you can provide `Database` object or - provide the params for creating it: - :param parent: + :param parent: parent object in LinkTo format. workspace can not be a parent :param properties: dict of properties. Property with `title` type is mandatory! :param title: your name of the Database :return: self.obj -> Database @@ -366,7 +366,7 @@ def page_create( """ :param page_obj: you can provide `Page` object or - provide the params for creating it: - :param parent: LinkTo object with ID of parent element + :param parent: LinkTo object with ID of parent element. workspace can not be a parent :param properties: Dict of properties with values :param title: New title :param children: Content of new page in [Block] or BlockArray format diff --git a/pytion/models.py b/pytion/models.py index 91b666e..a927e9f 100644 --- a/pytion/models.py +++ b/pytion/models.py @@ -941,6 +941,8 @@ def __init__( else: self.type: str = kwargs.get("type") self.id: str = kwargs.get(self.type) if kwargs.get(self.type) else kwargs.get("id") + if self.type == "workspace": + self.id = "" self.after_path = "" if self.type == "page_id": self.uri = "blocks" @@ -973,6 +975,8 @@ def link(self) -> str: return NOTION_URL + str(self) def get(self, without_type: bool = False): + if self.type == "workspace": + return {"type": "workspace", "workspace": True} if without_type: return {self.type: self.id} return {"type": self.type, self.type: self.id} @@ -982,6 +986,7 @@ def create(cls, **kwargs): """ `.create(page_id="123412341234")` `.create(database_id="13412341234")` + `.create(workspace=True)` """ for key, value in kwargs.items(): return cls(type=key, id=value)