974ed4eb3f
--- - Cria schema `BlockList` em `schemas.responses.blocks`; - Cria request `get` em `client.blocks`; - Modifica request `get_children` em `client.blocks` para deixar claro que o endpoint busca parentes de páginas e blocos; - Adiciona field `page_id` em `schemas.responses.pages.Parent`; - Cria pasta `blocks` em `schemas.responses` para guardar schemas de diversos tipos de objetos; - Cria schema `Block` em `schemas.responses.blocks`; - Cria schema `Toggle` em `schemas.responses.blocks`; - Cria pasta `misc` em `schemas.responses` e move schema `Parent` para lá; - Cria referência de `misc` e seus schemas em `notion.types.responses`; - Move pasta `properties` de `schemas.pages` para `schemas`; - Cria referência de `blocks` e seus schemas em `notion.types.responses`; - Cria referência de `properties` e seus schemas em `notion.types.responses`; - Remove pasta `.examples` de `orm.repositories.pages`; ---
37 lines
972 B
Python
Executable File
37 lines
972 B
Python
Executable File
import httpx
|
|
from typing import Dict
|
|
|
|
class Blocks:
|
|
|
|
"Reference: https://developers.notion.com/reference/retrieve-a-block"
|
|
|
|
def __init__(self, headers : Dict[str, str]):
|
|
self._headers = headers
|
|
|
|
async def get(self, block_id : str):
|
|
|
|
"Busca detalhes de um bloco"
|
|
|
|
async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
|
|
|
|
response = await client.get(
|
|
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
|
|
)
|
|
|
|
return response.json()
|
|
|
|
__all__ = ["Blocks"] |