"""
URL configuration for hotelfinder project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
from django.conf import settings
from django.conf.urls.static import static
from rest_framework_simplejwt.views import TokenRefreshView
from restaurant.whatsapp_webhook import WhatsAppWebhookView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('home.urls')),
    path('api/hotel/', include('hotel.urls')),
    path('api/restaurants/', include('restaurant.urls')),
    path('api/restaurant/', include('restaurant.urls')),  # Alias for Aahar compatibility
    path('restaurant/api/', include('restaurant.urls')),  # Alias for Aahar POS webhooks
    path('api/payment/', include('payments.urls')),
    path('api/users/', include('users.urls')),

    path('api/users/', include('users.urls')),
    # Legacy whatsapp/ app deprecated — consolidated into restaurant/whatsapp_webhook.py
    path('api/whatsapp/webhook/', WhatsAppWebhookView.as_view(), name='legacy-whatsapp-webhook'),
    path('whatsapp/webhook/', WhatsAppWebhookView.as_view(), name='root-whatsapp-webhook'),
    path('whatsapp/webhook', WhatsAppWebhookView.as_view(), name='root-whatsapp-webhook-no-slash'),
    path('webhook/whatsapp/', WhatsAppWebhookView.as_view(), name='webhook-whatsapp'),
    path('webhook/whatsapp', WhatsAppWebhookView.as_view(), name='webhook-whatsapp-no-slash'),
    path('interakt/webhook/', WhatsAppWebhookView.as_view(), name='interakt-webhook'),
    path('interakt/webhook', WhatsAppWebhookView.as_view(), name='interakt-webhook-no-slash'),
    path('api/auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),

    path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
    path('api/swagger/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
]

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