Added notifications!!

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-29 12:28:11 -06:00
parent 9e3cc3a03f
commit fef8ab225d
24 changed files with 3596 additions and 20 deletions

View File

@@ -270,8 +270,168 @@
"body": null
}
}
},
"notificaciones": {
"health_check": {
"metodo": "GET",
"url": "http://localhost:8002/",
"respuesta": {
"codigo": 200,
"body": {
"status": "ok",
"service": "Notificaciones Microservice"
}
}
},
"crear_notificacion": {
"metodo": "POST",
"url": "http://localhost:8002/notifications/",
"descripcion": "Crear notificación (uso interno, generalmente disparado por cambios de reportes)",
"solicitud": {
"Content-Type": "application/json",
"headers": {
"Authorization": "Bearer {jwt_token}"
},
"body": {
"id_usuario": 1,
"id_reporte": "550e8400-e29b-41d4-a716-446655440000",
"message": "¡Tu reporte ha sido resuelto!"
}
},
"respuesta_exitosa": {
"codigo": 200,
"body": {
"id_notificacion": "660f8401-f39c-41e5-b727-557666551111",
"id_usuario": 1,
"id_reporte": "550e8400-e29b-41d4-a716-446655440000",
"message": "¡Tu reporte ha sido resuelto!",
"fecha": "2024-04-29T15:30:00Z",
"read": false
}
}
},
"obtener_notificaciones_usuario": {
"metodo": "GET",
"url": "http://localhost:8002/notifications/1?limit=50&offset=0",
"descripcion": "Obtener todas las notificaciones de un usuario con paginación",
"headers": {
"Authorization": "Bearer {jwt_token}"
},
"query_params": {
"limit": "50 (máximo 100)",
"offset": "0 (para paginación)"
},
"respuesta": {
"codigo": 200,
"body": {
"total": 150,
"unread_count": 5,
"notifications": [
{
"id_notificacion": "660f8401-f39c-41e5-b727-557666551111",
"id_usuario": 1,
"id_reporte": "550e8400-e29b-41d4-a716-446655440000",
"message": "¡Tu reporte ha sido resuelto!",
"fecha": "2024-04-29T15:30:00Z",
"read": false
},
{
"id_notificacion": "660f8401-f39c-41e5-b727-557666551112",
"id_usuario": 1,
"id_reporte": "550e8400-e29b-41d4-a716-446655440001",
"message": "Tu reporte fue marcado como no resuelto.",
"fecha": "2024-04-29T14:20:00Z",
"read": true
}
]
}
}
},
"obtener_conteo_no_leidas": {
"metodo": "GET",
"url": "http://localhost:8002/notifications/1/unread-count",
"descripcion": "Obtener el número de notificaciones no leídas para un usuario",
"headers": {
"Authorization": "Bearer {jwt_token}"
},
"respuesta": {
"codigo": 200,
"body": {
"unread_count": 5
}
}
},
"marcar_como_leida": {
"metodo": "PUT",
"url": "http://localhost:8002/notifications/660f8401-f39c-41e5-b727-557666551111/read",
"descripcion": "Marcar una notificación específica como leída",
"headers": {
"Authorization": "Bearer {jwt_token}"
},
"respuesta_exitosa": {
"codigo": 200,
"body": {
"id_notificacion": "660f8401-f39c-41e5-b727-557666551111",
"id_usuario": 1,
"id_reporte": "550e8400-e29b-41d4-a716-446655440000",
"message": "¡Tu reporte ha sido resuelto!",
"fecha": "2024-04-29T15:30:00Z",
"read": true
}
}
},
"marcar_todas_como_leidas": {
"metodo": "PUT",
"url": "http://localhost:8002/notifications/1/read-all",
"descripcion": "Marcar todas las notificaciones de un usuario como leídas",
"headers": {
"Authorization": "Bearer {jwt_token}"
},
"respuesta_exitosa": {
"codigo": 200,
"body": {
"message": "All notifications marked as read",
"updated_count": 5
}
}
},
"eliminar_notificacion": {
"metodo": "DELETE",
"url": "http://localhost:8002/notifications/660f8401-f39c-41e5-b727-557666551111",
"descripcion": "Eliminar una notificación específica",
"headers": {
"Authorization": "Bearer {jwt_token}"
},
"respuesta_exitosa": {
"codigo": 200,
"body": {
"message": "Notification deleted successfully"
}
}
}
}
},
"cambios_estado_notificaciones": {
"transiciones": {
"en_proceso_a_resuelto": {
"mensaje": "¡Tu reporte #[id_reporte] ha sido resuelto!",
"tipo": "positivo"
},
"en_proceso_a_no_resuelto": {
"mensaje": "Tu reporte #[id_reporte] fue marcado como no resuelto.",
"tipo": "info"
},
"no_resuelto_a_resuelto": {
"mensaje": "¡Tu reporte #[id_reporte] ha sido resuelto!",
"tipo": "positivo"
},
"resuelto_a_en_proceso": {
"mensaje": "Tu reporte #[id_reporte] ha sido reabierto.",
"tipo": "info"
}
},
"trigger": "Cuando cambias el estado en PUT /reports/{report_id}/status"
},
"tipos_reporte": {
"1": "Infraestructura/Vía pública",
"2": "Inseguridad",
@@ -279,11 +439,31 @@
"4": "Servicios públicos",
"5": "Otro"
},
"apis_disponibles": {
"usuarios": {
"url": "http://localhost:8000",
"puerto": 8000,
"docs": "http://localhost:8000/docs"
},
"reportes": {
"url": "http://localhost:8001",
"puerto": 8001,
"docs": "http://localhost:8001/docs"
},
"notificaciones": {
"url": "http://localhost:8002",
"puerto": 8002,
"docs": "http://localhost:8002/docs",
"nuevo": true
}
},
"codigos_estado_http": {
"200": "OK - La solicitud fue exitosa",
"201": "Created - Recurso creado exitosamente",
"202": "Accepted - Solicitud aceptada en cola",
"204": "No Content - Eliminación exitosa",
"400": "Bad Request - Error en la solicitud",
"401": "Unauthorized - Token inválido/expirado",
"404": "Not Found - Recurso no encontrado",
"500": "Internal Server Error - Error en el servidor"
}