Compare commits
1 Commits
v0.1.0-beta
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 974ed4eb3f |
+16
-3
@@ -8,14 +8,27 @@ class Blocks:
|
|||||||
def __init__(self, headers : Dict[str, str]):
|
def __init__(self, headers : Dict[str, str]):
|
||||||
self._headers = headers
|
self._headers = headers
|
||||||
|
|
||||||
async def get_children(self, page_id : str):
|
async def get(self, block_id : str):
|
||||||
|
|
||||||
"Busca pelos blocos de uma página"
|
"Busca detalhes de um bloco"
|
||||||
|
|
||||||
async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
|
async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
|
||||||
|
|
||||||
response = await client.get(
|
response = await client.get(
|
||||||
f'https://api.notion.com/v1/blocks/{page_id}/children',
|
f'https://api.notion.com/v1/blocks/{block_id}',
|
||||||
|
headers = self._headers
|
||||||
|
)
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
|
||||||
|
async def get_children(self, block_id : str):
|
||||||
|
|
||||||
|
"Busca pelos blocos de um bloco ou página"
|
||||||
|
|
||||||
|
async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
|
||||||
|
|
||||||
|
response = await client.get(
|
||||||
|
f'https://api.notion.com/v1/blocks/{block_id}/children',
|
||||||
headers = self._headers
|
headers = self._headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
# async def main():
|
|
||||||
# instance = NotionOrm.repo.pages()
|
|
||||||
# create = await instance.CreatePage()\
|
|
||||||
# .set_parent("page_id", "2a564c9be67881a185c1c5d9133b9b1c")\
|
|
||||||
# .set_title("Name", "Teste abc")\
|
|
||||||
# .set_children("heading_1", "Teste")\
|
|
||||||
# .call()
|
|
||||||
# return create
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import sys, os, asyncio
|
|
||||||
sys.path.append(
|
|
||||||
os.path.abspath(
|
|
||||||
os.path.join(
|
|
||||||
os.path.dirname(__file__), '..', '..', '..', '..', '..', '..', '..'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
from src.utils.pprint import pprint
|
|
||||||
from src.integrations.notion.orm.repositories.pages.GetPage import GetPage
|
|
||||||
|
|
||||||
async def main():
|
|
||||||
instance = GetPage()
|
|
||||||
search = await instance\
|
|
||||||
.set_database(name="accounts")\
|
|
||||||
.set_pageid("0db2806f-b365-4327-919d-afbd1943f2ad")\
|
|
||||||
.select("Name")
|
|
||||||
#.call(True)
|
|
||||||
return search
|
|
||||||
|
|
||||||
test = await main()
|
|
||||||
pprint(test)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import sys, os, asyncio
|
|
||||||
sys.path.append(
|
|
||||||
os.path.abspath(
|
|
||||||
os.path.join(
|
|
||||||
os.path.dirname(__file__), '..', '..', '..', '..', '..', '..', '..'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
from src.utils.pprint import pprint
|
|
||||||
from src.integrations.notion.orm.repositories.pages.GetPageProperty import GetPageProperty
|
|
||||||
|
|
||||||
async def main():
|
|
||||||
instance = GetPageProperty()
|
|
||||||
search = await instance\
|
|
||||||
.set_pageid("0db2806f-b365-4327-919d-afbd1943f2ad")\
|
|
||||||
.set_propname("Movements")\
|
|
||||||
.call()
|
|
||||||
return search
|
|
||||||
|
|
||||||
test = await main()
|
|
||||||
pprint(test)
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
from ....schemas.dto import BaseModelSdk
|
from ....schemas.dto import BaseModelSdk
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
from typing import Dict, Any, List, Optional
|
from typing import List, Optional
|
||||||
from ...responses.pages.properties.RichText import RichText as _RichText
|
from ...responses.properties.RichText import RichText as _RichText
|
||||||
|
|
||||||
class RichText(BaseModelSdk):
|
class RichText(BaseModelSdk):
|
||||||
model_config = ConfigDict(title="Notion_Orm_Common_RichText")
|
model_config = ConfigDict(title = "Notion_Orm_Common_RichText")
|
||||||
text: Optional[str]
|
text: Optional[str]
|
||||||
detailed: List[_RichText]
|
detailed: List[_RichText]
|
||||||
|
|||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
from ...dto import BaseModelSdk
|
||||||
|
from pydantic import ConfigDict
|
||||||
|
from typing import Any, Union, Literal
|
||||||
|
from datetime import datetime
|
||||||
|
from ..users.User import User as _User
|
||||||
|
from ..misc.Parent import Parent as _Parent
|
||||||
|
from .Toggle import Toggle as _Toggle
|
||||||
|
|
||||||
|
class Block(BaseModelSdk):
|
||||||
|
model_config = ConfigDict(title = "Notion_Responses_Blocks_List")
|
||||||
|
object: str
|
||||||
|
id: str
|
||||||
|
parent: _Parent
|
||||||
|
created_time: datetime
|
||||||
|
last_edited_time: datetime
|
||||||
|
created_by: _User
|
||||||
|
last_edited_by: _User
|
||||||
|
has_children: bool
|
||||||
|
archived: bool
|
||||||
|
in_trash: bool
|
||||||
|
type: Literal[
|
||||||
|
"toggle"
|
||||||
|
]
|
||||||
|
block : Union[Any,
|
||||||
|
_Toggle
|
||||||
|
]
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
from ...dto import BaseModelSdk
|
||||||
|
from typing import Optional, List, Any, Union
|
||||||
|
from pydantic import ConfigDict, Field
|
||||||
|
from .Block import Block as _Block
|
||||||
|
|
||||||
|
class BlockList(BaseModelSdk):
|
||||||
|
model_config = ConfigDict(title = "Notion_Responses_Blocks_BlockList")
|
||||||
|
results: List[Union[_Block, Any]]
|
||||||
|
next_cursor: Optional[str] = None
|
||||||
|
has_more: bool
|
||||||
|
type: str = "block"
|
||||||
|
block: dict
|
||||||
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
from ...dto import BaseModelSdk
|
||||||
|
from pydantic import ConfigDict
|
||||||
|
from ..properties.RichText import RichText as _RichText
|
||||||
|
|
||||||
|
class Toggle(BaseModelSdk):
|
||||||
|
model_config = ConfigDict(title = "Notion_Responses_Blocks_Toggle")
|
||||||
|
rich_text : _RichText
|
||||||
|
color : str
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
from .Block import Block as _Block
|
||||||
|
from .BlockList import BlockList as _BlockList
|
||||||
|
from .Toggle import Toggle as _Toggle
|
||||||
|
|
||||||
|
class Schemas:
|
||||||
|
|
||||||
|
Block = _Block
|
||||||
|
BlockList = _BlockList
|
||||||
|
Toggle = _Toggle
|
||||||
|
|
||||||
|
__all__ = ["Schemas"]
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
from ....schemas.dto import BaseModelSdk
|
from ...dto import BaseModelSdk
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
from typing import Optional, Literal
|
from typing import Optional, Literal
|
||||||
|
|
||||||
class Parent(BaseModelSdk):
|
class Parent(BaseModelSdk):
|
||||||
model_config = ConfigDict(title="Notion_Responses_Pages_Parent")
|
model_config = ConfigDict(title="Notion_Responses_Misc_Parent")
|
||||||
type: Literal ["page_id", "data_source_id", "database_id"]
|
type: Literal ["page_id", "data_source_id", "database_id"]
|
||||||
data_source_id: Optional[str] = None
|
data_source_id: Optional[str] = None
|
||||||
database_id: Optional[str] = None
|
database_id: Optional[str] = None
|
||||||
|
page_id: Optional[str] = None
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
from .Parent import Parent as _Parent
|
||||||
|
|
||||||
|
class Schemas:
|
||||||
|
|
||||||
|
Parent = _Parent
|
||||||
|
|
||||||
|
__all__ = ["Schemas"]
|
||||||
@@ -4,7 +4,7 @@ from typing import Optional, Any, Dict, Generic, TypeVar, Union
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ....orm.mapping.database import NotionDatabase as _NotionDatabase
|
from ....orm.mapping.database import NotionDatabase as _NotionDatabase
|
||||||
from ..users.User import User as _User
|
from ..users.User import User as _User
|
||||||
from .Parent import Parent as _Parent
|
from ..misc.Parent import Parent as _Parent
|
||||||
|
|
||||||
TDB = TypeVar('TDB', bound = _NotionDatabase)
|
TDB = TypeVar('TDB', bound = _NotionDatabase)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
from .Page import Page as _Page
|
from .Page import Page as _Page
|
||||||
from .Parent import Parent as _Parent
|
|
||||||
|
|
||||||
class Schemas:
|
class Schemas:
|
||||||
|
|
||||||
Page = _Page
|
Page = _Page
|
||||||
Parent = _Parent
|
|
||||||
|
|
||||||
__all__ = ["Schemas"]
|
__all__ = ["Schemas"]
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
from .....schemas.dto import BaseModelSdk
|
from ....schemas.dto import BaseModelSdk
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
from typing import Dict, Any, Optional
|
from typing import Dict, Any, Optional
|
||||||
|
|
||||||
class RichText(BaseModelSdk):
|
class RichText(BaseModelSdk):
|
||||||
model_config = ConfigDict(title="Notion_Responses_Pages_Properties_RichText")
|
model_config = ConfigDict(title="Notion_Responses_Properties_RichText")
|
||||||
type: str
|
type: str
|
||||||
text: 'Text'
|
text: 'Text'
|
||||||
annotations: 'Annotations'
|
annotations: 'Annotations'
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
from ....schemas.responses.blocks.Block import Block
|
||||||
|
from ....schemas.responses.blocks.BlockList import BlockList
|
||||||
|
from ....schemas.responses.blocks.Toggle import Toggle
|
||||||
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
from ....schemas.responses.misc.Parent import Parent
|
||||||
@@ -1,2 +1 @@
|
|||||||
from ....schemas.responses.pages.Page import Page
|
from ....schemas.responses.pages.Page import Page
|
||||||
from ....schemas.responses.pages.Parent import Parent
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
from ....schemas.responses.properties.RichText import RichText
|
||||||
Reference in New Issue
Block a user