Add notion util
This commit is contained in:
@@ -4,6 +4,7 @@ from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
|
||||
from src.cloud_util.mqtt import MQTT
|
||||
from src.cloud_util.notion import NotionAsync
|
||||
from src.cloud_util.ticktick import TickTick
|
||||
from src.config import Config
|
||||
from src.recorder.poo import PooRecorder
|
||||
@@ -11,8 +12,9 @@ from src.recorder.poo import PooRecorder
|
||||
Config.init()
|
||||
|
||||
ticktick = TickTick()
|
||||
notion = NotionAsync(token=Config.get_env(key="NOTION_TOKEN"))
|
||||
mqtt = MQTT()
|
||||
poo_recorder = PooRecorder(mqtt)
|
||||
poo_recorder = PooRecorder(mqtt=mqtt, notion=notion)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
@@ -29,12 +31,14 @@ class PooRecordField(BaseModel):
|
||||
app = FastAPI(lifespan=_lifespan)
|
||||
|
||||
|
||||
# Poo recorder
|
||||
@app.post("/poo/record")
|
||||
async def record(record_detail: PooRecordField) -> PooRecordField:
|
||||
await poo_recorder.record(record_detail.status)
|
||||
return record_detail
|
||||
|
||||
|
||||
# ticktick
|
||||
@app.get("/ticktick/auth/code")
|
||||
async def ticktick_auth(code: str, state: str) -> dict:
|
||||
if ticktick.retrieve_access_token(code, state):
|
||||
|
||||
Reference in New Issue
Block a user