From 9b72b2ff27e43edd0f07e773fca4089486be933b Mon Sep 17 00:00:00 2001 From: Morgan Joyce Date: Sat, 21 Dec 2024 21:47:07 -0600 Subject: [PATCH] refactor: update Notion client integration and database schema retrieval - Replaced the `notion_client.Client` with `notion_automation.notion_client.NotionClient` for improved modularity. - Updated the authentication method to use `NOTION_API_KEY` instead of `NOTION_TOKEN`. - Modified the database retrieval method to align with the new client structure, enhancing clarity and maintainability. --- notion_automation/get_database.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notion_automation/get_database.py b/notion_automation/get_database.py index bee9b7e..b969151 100644 --- a/notion_automation/get_database.py +++ b/notion_automation/get_database.py @@ -1,20 +1,20 @@ import sys import json -from notion_client import Client +from notion_automation.notion_client import NotionClient import os from dotenv import load_dotenv def get_database_schema(database_id): """Retrieve and format the schema of a Notion database.""" load_dotenv() - notion = Client(auth=os.getenv("NOTION_TOKEN")) + notion = NotionClient(auth_token=os.getenv("NOTION_API_KEY")) try: - database = notion.databases.retrieve(database_id=database_id) + database = notion.get_database(database_id) # Extract and format the properties schema schema = { - "title": database["title"][0]["plain_text"] if database.get("title") else "", + "title": database["title"], "properties": {} }