notion_api에서 사용하던 정보를 config.py 로 이동

This commit is contained in:
2025-07-22 15:28:03 +09:00
parent 30f3806ae6
commit 7a86d28415
2 changed files with 17 additions and 7 deletions

View File

@ -12,6 +12,16 @@ class Config:
# 노션 API
NOTION_API_SECRET = os.getenv('NOTION_API_SECRET')
NOTION_API_BASE = "https://api.notion.com/v1"
NOTION_VERSION = "2022-06-28"
@classmethod
def get_notion_headers(cls):
return {
"Authorization": f"Bearer {cls.NOTION_API_SECRET}",
"Notion-Version": cls.NOTION_VERSION,
"Content-Type": "application/json"
}
# 웹훅 서명 검증용 비밀키 (옵션)
NOTION_WEBHOOK_SECRET = os.getenv('NOTION_WEBHOOK_SECRET', None)

View File

@ -13,8 +13,8 @@ from lib.config import Config
from lib.common import EVENT_TYPE_LABELS
def get_page_details(page_id: str) -> Optional[Dict]:
url = f"{NOTION_API_BASE}/pages/{page_id}"
response = requests.get(url, headers=HEADERS)
url = f"{Config.NOTION_API_BASE}/pages/{page_id}"
response = requests.get(url, headers=Config.HEADERS)
if response.status_code == 200:
return response.json()
@ -147,17 +147,17 @@ def fetch_entity_detail(entity_type: str, entity_id: str) -> Optional[Dict]:
"""
url = None
if entity_type == "page":
url = f"{NOTION_API_BASE}/pages/{entity_id}"
url = f"{Config.NOTION_API_BASE}/pages/{entity_id}"
elif entity_type == "database":
url = f"{NOTION_API_BASE}/databases/{entity_id}"
url = f"{Config.NOTION_API_BASE}/databases/{entity_id}"
elif entity_type == "block":
url = f"{NOTION_API_BASE}/blocks/{entity_id}/children"
url = f"{Config.NOTION_API_BASE}/blocks/{entity_id}/children"
else:
logging.warning(f"알 수 없는 entity_type: {entity_type}")
return None
try:
response = requests.get(url, headers=HEADERS, timeout=5)
response = requests.get(url, headers=Config.HEADERS, timeout=5)
response.raise_for_status()
return response.json()
except Exception as e: