Skip to content

Commit

Permalink
fix #12. tests ok
Browse files Browse the repository at this point in the history
  • Loading branch information
lastorel committed May 10, 2022
1 parent 0281c67 commit 00ec9c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`

Expand Down Expand Up @@ -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"`.
Expand Down
4 changes: 2 additions & 2 deletions pytion/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pytion/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}
Expand All @@ -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)

0 comments on commit 00ec9c9

Please sign in to comment.