"""
URL routes for billing API endpoints.
"""

from django.urls import path, include
from rest_framework.routers import DefaultRouter

from smoothschedule.billing.api.views import (
    AddOnCatalogView,
    CurrentSubscriptionView,
    EntitlementsView,
    InvoiceDetailView,
    InvoiceListView,
    PlanCatalogView,
    # Admin ViewSets
    FeatureViewSet,
    PlanViewSet,
    PlanVersionViewSet,
    AddOnProductViewSet,
)

app_name = "billing"

# Admin router for platform admin management
admin_router = DefaultRouter()
admin_router.register(r"features", FeatureViewSet, basename="admin-feature")
admin_router.register(r"plans", PlanViewSet, basename="admin-plan")
admin_router.register(r"plan-versions", PlanVersionViewSet, basename="admin-plan-version")
admin_router.register(r"addons", AddOnProductViewSet, basename="admin-addon")

urlpatterns = [
    # /api/me/ endpoints (current user/business context)
    path("me/entitlements/", EntitlementsView.as_view(), name="me-entitlements"),
    path("me/subscription/", CurrentSubscriptionView.as_view(), name="me-subscription"),
    # /api/billing/ endpoints (public catalog)
    path("billing/plans/", PlanCatalogView.as_view(), name="plan-catalog"),
    path("billing/addons/", AddOnCatalogView.as_view(), name="addon-catalog"),
    path("billing/invoices/", InvoiceListView.as_view(), name="invoice-list"),
    path(
        "billing/invoices/<int:invoice_id>/",
        InvoiceDetailView.as_view(),
        name="invoice-detail",
    ),
    # /api/billing/admin/ endpoints (platform admin management)
    path("billing/admin/", include(admin_router.urls)),
]
