import datetime

from fastapi import APIRouter

from gallery.easel.core import AppRequest
from gallery.easel.depends.schedule import ScheduleApiDepends
from gallery.sketch.schedule.api import ScheduleApi
from gallery.sketch.schedule.model import Channel, Schedule

router = APIRouter(prefix="/schedule", tags=["Schedule"])


@router.get("/providers")
async def get_api_weather_providers(request: AppRequest) -> list[str]:
    return request.app.state.api.get_api_providers(ScheduleApi)


@router.get("/{provider}/channels")
async def find_api_schedule_channels(schedule_api: ScheduleApiDepends, query: str) -> list[Channel]:
    return await schedule_api.find_channels(query)


@router.get("/{provider}/{channel}/{date}")
async def get_api_schedule_channel_schedule(
    schedule_api: ScheduleApiDepends, channel: str, date: datetime.date
) -> Schedule:
    return await schedule_api.get_schedule(channel, date)
