import express from "express";
import { verifyToken, authorizeModules } from "../middlewares/authJwt";
import {
  createCampaign,
  listCampaigns,
  sendCampaignNow,
  listDeliveries,
  getMyNotifications,
  markMyAsRead,
  cancelCampaign,
  getCampaignReadCount,
  getUpcomingPaymentNotificationDaysHandler,
  replaceUpcomingPaymentNotificationDaysHandler,
  addUpcomingPaymentNotificationDayHandler,
  removeUpcomingPaymentNotificationDayHandler,
} from "../controllers/notificationV2Controller";

const router = express.Router();

/**
 * @swagger
 * tags:
 *   name: NotificationsV2
 *   description: Campaigns and user inbox
 */

/**
 * @swagger
 * components:
 *   securitySchemes:
 *     bearerAuth:
 *       type: http
 *       scheme: bearer
 *       bearerFormat: JWT
 *   schemas:
 *     Campaign:
 *       type: object
 *       properties:
 *         _id:
 *           type: string
 *         audience:
 *           type: string
 *           enum: [USER, ADMIN]
 *         type:
 *           type: string
 *           enum: [MOBILE, EMAIL, INTERNAL, SMS]
 *         infoType:
 *           type: string
 *           enum: [NEUTRAL, SUCCESS, WARNING, ERROR, BAN]
 *         title:
 *           type: string
 *         description:
 *           type: string
 *         imageUrl:
 *           type: string
 *           nullable: true
 *         link:
 *           type: string
 *           nullable: true
 *         users:
 *           type: array
 *           items:
 *             type: string
 *         group:
 *           type: string
 *           nullable: true
 *         sendAt:
 *           type: string
 *           format: date-time
 *           nullable: true
 *         status:
 *           type: string
 *           enum: [draft, scheduled, processing, sent, failed, cancelled]
 *         createdAt:
 *           type: string
 *           format: date-time
 *         updatedAt:
 *           type: string
 *           format: date-time
 *     CreateCampaignRequest:
 *       type: object
 *       required: [type, title, description]
 *       properties:
 *         audience:
 *           type: string
 *           enum: [USER, ADMIN]
 *           default: USER
 *         type:
 *           type: string
 *           enum: [MOBILE, EMAIL, INTERNAL, SMS]
 *         infoType:
 *           type: string
 *           enum: [NEUTRAL, SUCCESS, WARNING, ERROR, BAN]
 *           default: NEUTRAL
 *         title:
 *           type: string
 *         description:
 *           type: string
 *         imageUrl:
 *           type: string
 *         link:
 *           type: string
 *         users:
 *           type: array
 *           items:
 *             type: string
 *         group:
 *           type: string
 *         sendAt:
 *           type: string
 *           format: date-time
 *       example:
 *         type: EMAIL
 *         title: "Hola {{name}}"
 *         description: "Tu documento: {{document}}"
 *         imageUrl: "https://cdn.example.com/image.jpg"
 *         link: "https://example.com/action"
 *         users: ["665e3e2f2a9bd8c4b2c11111"]
 *         group: "665e3e2f2a9bd8c4b2c99999"
 *         sendAt: "2025-09-25T17:00:00-04:00"
 *     Delivery:
 *       type: object
 *       properties:
 *         _id:
 *           type: string
 *         campaignId:
 *           type: string
 *         recipientType:
 *           type: string
 *           enum: [USER, ADMIN]
 *         type:
 *           type: string
 *           enum: [MOBILE, EMAIL, INTERNAL, SMS]
 *         infoType:
 *           type: string
 *           enum: [NEUTRAL, SUCCESS, WARNING, ERROR, BAN]
 *         title:
 *           type: string
 *         description:
 *           type: string
 *         imageUrl:
 *           type: string
 *           nullable: true
 *         link:
 *           type: string
 *           nullable: true
 *         userId:
 *           type: string
 *           nullable: true
 *         adminId:
 *           type: string
 *           nullable: true
 *         status:
 *           type: string
 *           enum: [queued, sent, failed, read]
 *         readAt:
 *           type: string
 *           format: date-time
 *           nullable: true
 *         createdAt:
 *           type: string
 *           format: date-time
 *         updatedAt:
 *           type: string
 *           format: date-time
 *         recipient:
 *           type: object
 *           properties:
 *             name:
 *               type: string
 *             lastname:
 *               type: string
 *             email:
 *               type: string
 *             document:
 *               type: string
 *       example:
 *         _id: "665e3e2f2a9bd8c4b2caaaaa"
 *         campaignId: "665e3e2f2a9bd8c4b2cbbbb"
 *         type: EMAIL
 *         title: "Hola Juan"
 *         description: "Tu documento: V12345678"
 *         link: "https://example.com/action"
 *         userId: "665e3e2f2a9bd8c4b2c11111"
 *         status: "sent"
 *         createdAt: "2025-09-25T16:10:00.000Z"
 *         updatedAt: "2025-09-25T16:10:02.000Z"
 *     MarkAsReadRequest:
 *       type: object
 *       required: [ids]
 *       properties:
 *         ids:
 *           type: array
 *           items:
 *             type: string
 */

router.use(verifyToken);

/**
 * @swagger
 * /notifications-v2/me:
 *   get:
 *     operationId: getMyNotifications
 *     tags: [NotificationsV2]
 *     summary: List logged-in user's notifications
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: query
 *         name: page
 *         schema:
 *           type: integer
 *           default: 1
 *       - in: query
 *         name: size
 *         schema:
 *           type: integer
 *           default: 10
 *       - in: query
 *         name: status
 *         schema:
 *           type: string
 *           enum: [queued, sent, failed, read]
 *       - in: query
 *         name: from
 *         schema:
 *           type: string
 *           format: date-time
 *       - in: query
 *         name: to
 *         schema:
 *           type: string
 *           format: date-time
 *       - in: query
 *         name: infoType
 *         schema:
 *           type: string
 *           enum: [NEUTRAL, SUCCESS, WARNING, ERROR, BAN]
 *     responses:
 *       200:
 *         description: Notificaciones del usuario obtenidas correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Notifications retrieved"
 *                 data:
 *                   type: object
 *                   properties:
 *                     data:
 *                       type: array
 *                       items:
 *                         $ref: '#/components/schemas/Delivery'
 *                     pageInfo:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           totalRecords:
 *                             type: integer
 *                     unreadCount:
 *                       type: integer
 *             example:
 *               success: true
 *               message: "Notifications retrieved"
 *               data:
 *                 data:
 *                   - _id: "665e3e2f2a9bd8c4baaaaa"
 *                     campaignId: "665e3e2f2a9bd8c4bbbbbb"
 *                     type: EMAIL
 *                     title: "Hola Juan"
 *                     description: "Tu documento: V12345678"
 *                     status: "sent"
 *                     createdAt: "2025-03-09T10:00:00.000Z"
 *                 pageInfo:
 *                   - totalRecords: 15
 *                 unreadCount: 3
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 */
router.route("/me").get(getMyNotifications);
/**
 * @swagger
 * /notifications-v2/me/mark-as-read:
 *   post:
 *     operationId: markMyNotificationsAsRead
 *     tags: [NotificationsV2]
 *     summary: Marcar notificaciones del usuario como leídas
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/MarkAsReadRequest'
 *           example:
 *             ids: ["665e3e2f2a9bd8c4baaaaa", "665e3e2f2a9bd8c4bbbbbb"]
 *     responses:
 *       200:
 *         description: Notificaciones marcadas como leídas correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Notifications marked as read"
 *                 data:
 *                   type: object
 *                   properties:
 *                     modified:
 *                       type: integer
 *                       description: Cantidad de notificaciones actualizadas
 *             example:
 *               success: true
 *               message: "Notifications marked as read"
 *               data:
 *                 modified: 2
 *       400:
 *         description: IDs inválidos
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: "Invalid ids"
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 */
router.route("/me/mark-as-read").post(markMyAsRead);

// Admin/manager endpoints
router.use(authorizeModules("notifications"));
/**
 * @swagger
 * /notifications-v2:
 *   post:
 *     operationId: createNotificationCampaign
 *     tags: [NotificationsV2]
 *     summary: Crear campaña de notificaciones
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/CreateCampaignRequest'
 *     responses:
 *       201:
 *         description: Campaña creada correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Campaign created"
 *                 data:
 *                   $ref: '#/components/schemas/Campaign'
 *             example:
 *               success: true
 *               message: "Campaign created"
 *               data:
 *                 _id: "665e3e2f2a9bd8c4b2c12345"
 *                 audience: "USER"
 *                 type: "EMAIL"
 *                 infoType: "NEUTRAL"
 *                 title: "Hola {{name}}"
 *                 description: "Tu documento: {{document}}"
 *                 status: "draft"
 *                 createdAt: "2025-03-09T10:00:00.000Z"
 *       400:
 *         description: Payload inválido o falta target (users/group)
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *             example:
 *               success: false
 *               message: "Provide at least one target: users or group"
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 *   get:
 *     operationId: listNotificationCampaigns
 *     tags: [NotificationsV2]
 *     summary: Listar campañas
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: query
 *         name: status
 *         schema:
 *           type: string
 *           enum: [draft, scheduled, processing, sent, failed, cancelled]
 *       - in: query
 *         name: from
 *         schema:
 *           type: string
 *           format: date-time
 *       - in: query
 *         name: to
 *         schema:
 *           type: string
 *           format: date-time
 *       - in: query
 *         name: page
 *         schema:
 *           type: integer
 *           default: 1
 *       - in: query
 *         name: size
 *         schema:
 *           type: integer
 *           default: 10
 *       - in: query
 *         name: search
 *         schema:
 *           type: string
 *         description: Buscar en título o descripción
 *       - in: query
 *         name: infoType
 *         schema:
 *           type: string
 *           enum: [NEUTRAL, SUCCESS, WARNING, ERROR, BAN]
 *     responses:
 *       200:
 *         description: Lista de campañas obtenida correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Campaigns retrieved"
 *                 data:
 *                   type: object
 *                   properties:
 *                     data:
 *                       type: array
 *                       items:
 *                         $ref: '#/components/schemas/Campaign'
 *                     pageInfo:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           totalRecords:
 *                             type: integer
 *             example:
 *               success: true
 *               message: "Campaigns retrieved"
 *               data:
 *                 data:
 *                   - _id: "665e3e2f2a9bd8c4b2c12345"
 *                     audience: "USER"
 *                     type: "EMAIL"
 *                     title: "Promoción"
 *                     status: "sent"
 *                 pageInfo:
 *                   - totalRecords: 1
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 */
router.route("/").post(createCampaign).get(listCampaigns);
/**
 * @swagger
 * /notifications-v2/{id}/send:
 *   post:
 *     operationId: sendNotificationCampaign
 *     tags: [NotificationsV2]
 *     summary: Enviar campaña inmediatamente
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: ID de la campaña
 *     responses:
 *       200:
 *         description: Campaña procesada correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Campaign processed"
 *       400:
 *         description: ID inválido
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: "Invalid id"
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 *       404:
 *         description: Campaña no encontrada
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: "Campaign not found"
 */
router.route("/:id/send").post(sendCampaignNow);
/**
 * @swagger
 * /notifications-v2/{id}/read-count:
 *   get:
 *     operationId: getNotificationReadCount
 *     tags: [NotificationsV2]
 *     summary: Obtener cantidad de notificaciones leídas de una campaña
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: ID de la campaña
 *     responses:
 *       200:
 *         description: Conteo obtenido correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Read count retrieved"
 *                 data:
 *                   type: object
 *                   properties:
 *                     readCount:
 *                       type: integer
 *             example:
 *               success: true
 *               message: "Read count retrieved"
 *               data:
 *                 readCount: 42
 *       400:
 *         description: ID inválido
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: "Invalid id"
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 */
router.route("/:id/read-count").get(getCampaignReadCount);
/**
 * @swagger
 * /notifications-v2/{id}/cancel:
 *   post:
 *     operationId: cancelNotificationCampaign
 *     tags: [NotificationsV2]
 *     summary: Cancelar campaña programada o borrador
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: ID de la campaña
 *     responses:
 *       200:
 *         description: Campaña cancelada correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Campaign cancelled"
 *                 data:
 *                   type: object
 *                   properties:
 *                     id:
 *                       type: string
 *                     status:
 *                       type: string
 *                       example: "cancelled"
 *             example:
 *               success: true
 *               message: "Campaign cancelled"
 *               data:
 *                 id: "665e3e2f2a9bd8c4b2c12345"
 *                 status: "cancelled"
 *       400:
 *         description: ID inválido o estado no permite cancelar
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *             example:
 *               success: false
 *               message: "Cannot cancel campaign in status: sent"
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 *       404:
 *         description: Campaña no encontrada
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: "Campaign not found"
 */
router.route("/:id/cancel").post(cancelCampaign);
/**
 * @swagger
 * /notifications-v2/deliveries:
 *   get:
 *     operationId: getNotificationDeliveries
 *     tags: [NotificationsV2]
 *     summary: Listar entregas de campañas
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: query
 *         name: campaignId
 *         schema:
 *           type: string
 *         description: Filtrar por ID de campaña
 *       - in: query
 *         name: status
 *         schema:
 *           type: string
 *           enum: [queued, sent, failed, read]
 *       - in: query
 *         name: from
 *         schema:
 *           type: string
 *           format: date-time
 *       - in: query
 *         name: to
 *         schema:
 *           type: string
 *           format: date-time
 *       - in: query
 *         name: page
 *         schema:
 *           type: integer
 *           default: 1
 *       - in: query
 *         name: size
 *         schema:
 *           type: integer
 *           default: 10
 *       - in: query
 *         name: search
 *         schema:
 *           type: string
 *         description: Buscar en título o descripción
 *       - in: query
 *         name: infoType
 *         schema:
 *           type: string
 *           enum: [NEUTRAL, SUCCESS, WARNING, ERROR, BAN]
 *     responses:
 *       200:
 *         description: Lista de entregas obtenida correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Deliveries retrieved"
 *                 data:
 *                   type: object
 *                   properties:
 *                     data:
 *                       type: array
 *                       items:
 *                         $ref: '#/components/schemas/Delivery'
 *                     pageInfo:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           totalRecords:
 *                             type: integer
 *             example:
 *               success: true
 *               message: "Deliveries retrieved"
 *               data:
 *                 data:
 *                   - _id: "665e3e2f2a9bd8c4b2caaaaa"
 *                     campaignId: "665e3e2f2a9bd8c4b2cbbbbb"
 *                     type: "EMAIL"
 *                     title: "Hola Juan"
 *                     description: "Tu documento: V12345678"
 *                     status: "sent"
 *                     createdAt: "2025-03-09T10:00:00.000Z"
 *                 pageInfo:
 *                   - totalRecords: 25
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 */
router.route("/deliveries").get(listDeliveries);

/**
 * @swagger
 * /notifications-v2/settings/upcoming-payment-days:
 *   get:
 *     operationId: getUpcomingPaymentDays
 *     tags: [NotificationsV2]
 *     summary: Obtener días configurados para notificaciones de pago próximo
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: Días obtenidos correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Notification days retrieved"
 *                 data:
 *                   type: object
 *                   properties:
 *                     days:
 *                       type: array
 *                       items:
 *                         type: integer
 *             example:
 *               success: true
 *               message: "Notification days retrieved"
 *               data:
 *                 days: [7, 3, 1, 0]
 *       500:
 *         description: Error al obtener días
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: "Error retrieving notification days"
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 *   put:
 *     operationId: replaceUpcomingPaymentDays
 *     tags: [NotificationsV2]
 *     summary: Reemplazar lista de días de notificación
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required: [days]
 *             properties:
 *               days:
 *                 type: array
 *                 items:
 *                   type: integer
 *                   minimum: 0
 *                 minItems: 1
 *           example:
 *             days: [7, 3, 1, 0]
 *     responses:
 *       200:
 *         description: Días actualizados correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Notification days updated"
 *                 data:
 *                   type: object
 *                   properties:
 *                     days:
 *                       type: array
 *                       items:
 *                         type: integer
 *             example:
 *               success: true
 *               message: "Notification days updated"
 *               data:
 *                 days: [7, 3, 1, 0]
 *       400:
 *         description: Payload inválido
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 *   post:
 *     operationId: addUpcomingPaymentDay
 *     tags: [NotificationsV2]
 *     summary: Agregar día a la lista de notificaciones
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required: [day]
 *             properties:
 *               day:
 *                 type: integer
 *                 minimum: 0
 *           example:
 *             day: 14
 *     responses:
 *       200:
 *         description: Día agregado correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Notification day added"
 *                 data:
 *                   type: object
 *                   properties:
 *                     days:
 *                       type: array
 *                       items:
 *                         type: integer
 *             example:
 *               success: true
 *               message: "Notification day added"
 *               data:
 *                 days: [14, 7, 3, 1, 0]
 *       400:
 *         description: Payload inválido o día ya existe
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 */
router
  .route("/settings/upcoming-payment-days")
  .get(getUpcomingPaymentNotificationDaysHandler)
  .put(replaceUpcomingPaymentNotificationDaysHandler)
  .post(addUpcomingPaymentNotificationDayHandler);

/**
 * @swagger
 * /notifications-v2/settings/upcoming-payment-days/{day}:
 *   delete:
 *     operationId: deleteUpcomingPaymentDay
 *     tags: [NotificationsV2]
 *     summary: Eliminar día de la lista de notificaciones
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: day
 *         required: true
 *         schema:
 *           type: integer
 *           minimum: 0
 *         description: Día a eliminar (ej. 7 para 7 días antes)
 *         example: 7
 *     responses:
 *       200:
 *         description: Día eliminado correctamente
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               required: [success, message, data]
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: "Notification day removed"
 *                 data:
 *                   type: object
 *                   properties:
 *                     days:
 *                       type: array
 *                       items:
 *                         type: integer
 *             example:
 *               success: true
 *               message: "Notification day removed"
 *               data:
 *                 days: [3, 1, 0]
 *       400:
 *         description: Día inválido o no se puede eliminar el último día
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: "Invalid day parameter. Must be a number."
 *       401:
 *         $ref: "#/components/responses/Unauthorized"
 *       403:
 *         $ref: "#/components/responses/Forbidden"
 */
router
  .route("/settings/upcoming-payment-days/:day")
  .delete(removeUpcomingPaymentNotificationDayHandler);

export default router;
