"""
Rutas de la version 1 del servicio de notificaciones.

Las cuatro primeras se conservan tal cual estaban para no romper a los
sistemas que ya las usan. El resto son nuevas.

    POST /notifications/v1/whatsapp/send/template   plantilla de WhatsApp
    POST /notifications/v1/whatsapp/send            conversacion de WhatsApp
    POST /notifications/v1/sms/send                 SMS
    POST /notifications/v1/mail/send/template       notificacion de sistema
    POST /notifications/v1/mail/send                correo con control completo
    GET  /notifications/v1/mail/<uuid>              estado de un envio
    POST /notifications/v1/webhooks/sendgrid        eventos de entrega (firmado)
    GET  /notifications/v1/health                   comprobacion de vida
    GET  /notifications/v1/health/ready             comprobacion de dependencias
"""

from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns

from notifications.controllers.v1 import health
from notifications.controllers.v1 import status as status_views
from notifications.controllers.v1.mail import conversation as mail_conversation
from notifications.controllers.v1.sms import conversation as sms_conversation
from notifications.controllers.v1.webhooks import sendgrid as sendgrid_webhook
from notifications.controllers.v1.webhooks import twilio as twilio_webhook
from notifications.controllers.v1.whatsapp import (
    conversation as whatsapp_conversation,
)
from notifications.controllers.v1.whatsapp import (
    template as whatsapp_template,
)

app_name = "v1"

urlpatterns = [
    # --- Contrato existente, sin cambios ---
    path(
        "whatsapp/send/template",
        whatsapp_template.Send.as_view(),
        name="whatsapp-send-template",
    ),
    path(
        "whatsapp/send",
        whatsapp_conversation.Send.as_view(),
        name="whatsapp-send",
    ),
    path("sms/send", sms_conversation.Send.as_view(), name="sms-send"),
    path(
        "mail/send/template",
        mail_conversation.Send.as_view(),
        name="mail-send-template",
    ),
    # --- Nuevo ---
    path("mail/send", mail_conversation.SendMail.as_view(), name="mail-send"),
    path(
        "mail/<uuid:pk>",
        mail_conversation.MailStatus.as_view(),
        name="mail-status",
    ),
    path(
        "webhooks/sendgrid",
        sendgrid_webhook.SendGridEventWebhook.as_view(),
        name="sendgrid-webhook",
    ),
    path(
        "webhooks/twilio/<uuid:message_id>",
        twilio_webhook.TwilioStatusWebhook.as_view(),
        name="twilio-webhook",
    ),
    path(
        "messages/<uuid:pk>",
        status_views.MessageStatus.as_view(),
        name="message-status",
    ),
    path("health", health.Liveness.as_view(), name="health"),
    path("health/ready", health.Readiness.as_view(), name="health-ready"),
]

urlpatterns = format_suffix_patterns(urlpatterns)
