from fastapi import APIRouter

from app.services.d2l import D2LService


router = APIRouter(prefix="/api/d2l", tags=["d2l"])
service = D2LService()


@router.get("/courses")
async def get_courses():
    return {"items": service.get_courses()}


@router.get("/assignments")
async def get_course_assignments(course_id: str):
    return {"items": service.get_assignments(course_id), "course_id": course_id}


@router.get("/grades")
async def get_course_grades(course_id: str):
    return service.get_grades(course_id)


@router.post("/sync")
async def sync_d2l():
    return service.sync_to_store()
