# Copyright 2025 Softwell S.r.l.
# Licensed under the Apache License, Version 2.0

"""Minimal example app for smoke testing with nested routing."""

from typing import Any

from genro_asgi import AsgiApplication
from genro_routes import RoutingClassAuto, route  # type: ignore[import-untyped]


class Employee(RoutingClassAuto):
    """Nested router for employee management."""

    @route()
    def list(self) -> dict[str, list[str]]:
        """List employees."""
        return {"employees": ["Alice", "Bob", "Charlie"]}

    @route()
    def get(self, id: int = 1) -> dict[str, str | int]:
        """Get employee by id."""
        return {"id": id, "name": "Alice", "department": "Engineering"}


class Office(RoutingClassAuto):
    """Office router with nested Employee."""

    def __init__(self) -> None:
        self.employee = Employee()
        self.routing.attach_instance(self.employee, name="employee")

    @route()
    def info(self) -> dict[str, str]:
        """Office info."""
        return {"name": "Main Office", "location": "Rome"}


class Application(AsgiApplication):
    """Minimal app with nested routing for smoke testing.

    Routes:
        /app/hello                    - Hello endpoint
        /app/health                   - Health check
        /app/office/info              - Office info
        /app/office/employee/list     - List employees
        /app/office/employee/get      - Get employee by id
    """

    def on_init(self, **kwargs: Any) -> None:
        """Setup nested routers."""
        self.office = Office()
        self.main.attach_instance(self.office, name="office")

    @route()
    def hello(self, name: str = "World") -> dict[str, str]:
        """Hello endpoint."""
        return {"message": f"Hello, {name}!"}

    @route()
    def health(self) -> dict[str, str]:
        """Health check endpoint."""
        return {"status": "ok"}


if __name__ == "__main__":
    pass
