"""
CODH Platform URL Configuration
"""

from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

def trigger_error(request):
    """Sentry test endpoint"""
    division_by_zero = 1 / 0

urlpatterns = [
    # Admin
    path('admin/', admin.site.urls),
    
    # Setup Wizard (First Load)
    path('api/setup/', include('codh_core.urls')),
    
    # Authentication
    path('api/auth/login/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('api/auth/', include('apps.users.urls')),
    
    # Core APIs
    path('api/users/', include('apps.users.urls')),
    path('api/projects/', include('apps.projects.urls')),
    path('api/hosting/', include('apps.hosting.urls')),
    path('api/subscriptions/', include('apps.subscriptions.urls')),
    path('api/payments/', include('apps.payments.urls')),
    path('api/ai/', include('apps.ai_engine.urls')),
    path('api/wordpress/', include('apps.wordpress.urls')),
    path('api/deployments/', include('apps.deployments.urls')),
    path('api/analytics/', include('apps.analytics.urls')),
    path('api/notifications/', include('apps.notifications.urls')),
    
    # Webhooks
    path('webhooks/paystack/', include('apps.payments.webhooks')),
    path('webhooks/flutterwave/', include('apps.payments.webhooks')),
    path('webhooks/stripe/', include('apps.payments.webhooks')),
    path('webhooks/wordpress/', include('apps.wordpress.webhooks')),
    
    # Health Check
    path('health/', include('codh_core.health')),
    
    # Sentry Test
    path('sentry-debug/', trigger_error),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
