aff0446458
--- - Cria singleton de `client` com func `configure` para inicializar e `get_instance` para buscar instância do client; - Ajusta clients para buscar headers vindo do pai `client` e fixa versão legacy no client de databases; - Adiciona inicialização de `client` no init do projeto com api_token e api_version informados pelo usuário; - Altera `NotionConfig` para inserir `database_id` no lugar de `database_name`; - Altera sistema para receber `database_id` no lugar de `database_name`; - Altera tipo de `properties` em `schemas.responses.pages.Page` de `Union[Dict[str, Any]], TDB` para `Union[Any, TDB]` para resolver reclamações de type hint; - Adiciona param `generic_response` no init de `client` e nos clients e databases e pages para pular uso de mapping ao usar `.generic`; - Adiciona param `raw_response` para pular parser e mappings e retornar resposta original da api; - Finaliza `types` com subpastas para importações mas com init mãe vazio para evitar dependência circular e permitir uso de `notion.types.` pelo usuário; - Remove importações do projeto original não relacionadas com o SDK; - Adiciona param `timezone` na func `start_date` em `orm.common.SetProperty` que antes vinha do env, para posteriormente puxar da init da integração; - Monta `LICENSE`, `README.md` e `pyproject.toml` base simples para commit inicial do projeto permitindo build de pacote; ---
63 lines
1.7 KiB
Python
Executable File
63 lines
1.7 KiB
Python
Executable File
from pydantic import validate_call
|
|
from typing import Dict, Any, Optional
|
|
from ....schemas.responses.errors.Error import Error as _schmError
|
|
from ....client import get_client as _get_client
|
|
from ...parsers.PageProperties import PageProperties as _PageProperties
|
|
|
|
class GetPageProperty:
|
|
|
|
"""
|
|
# CUIDADO AO UTILIZAR!!
|
|
### [Bug Conhecido](https://community.latenode.com/t/notion-api-relation-property-showing-empty-array-despite-ui-showing-connected-pages/25780) na API do Notion impede retornos confiáveis em propriedades paginadas
|
|
Ultimo teste : 2026-01-10
|
|
"""
|
|
|
|
def __init__(self) -> None:
|
|
self._pageid : str
|
|
self._propname : str
|
|
|
|
@validate_call
|
|
def set_pageid(self,
|
|
id : str
|
|
):
|
|
self._pageid = id
|
|
return self
|
|
|
|
@validate_call
|
|
def set_propname(self,
|
|
name : str
|
|
):
|
|
self._propname = name
|
|
return self
|
|
|
|
async def call(self,
|
|
raw_response : bool = False
|
|
) -> Optional[Dict[str, Any]]:
|
|
|
|
client = _get_client()
|
|
|
|
getprop = await client.pages.get_property(
|
|
page_id = self._pageid,
|
|
property_name = self._propname
|
|
)
|
|
|
|
if getprop['object'] == 'error':
|
|
error = _schmError(**getprop)
|
|
raise KeyError(error.__dict__)
|
|
|
|
prop_data = getprop.get("results")
|
|
if getprop.get("object") == "property_item":
|
|
prop_data = [getprop]
|
|
if not prop_data:
|
|
return None
|
|
|
|
if not raw_response:
|
|
|
|
result = _PageProperties.parse(
|
|
page = prop_data[0]
|
|
)
|
|
|
|
result = prop_data[0]
|
|
|
|
return result
|
|
|