diff --git a/docs/guias/api-reference.md b/docs/guias/api-reference.md index 1283db3..95c5b6a 100644 --- a/docs/guias/api-reference.md +++ b/docs/guias/api-reference.md @@ -55,7 +55,7 @@ Authorization: Bearer eyJ... ## Vehiculos -### Listar Vehiculos +### Listar Vehiculos (Paginado) ```http GET /vehiculos @@ -63,10 +63,13 @@ GET /vehiculos **Parametros query**: - `activo`: boolean - Filtrar por activos +- `en_servicio`: boolean - Filtrar por en servicio - `grupo_id`: integer - Filtrar por grupo -- `search`: string - Buscar por nombre/placa -- `page`: integer - Pagina (default: 1) -- `per_page`: integer - Items por pagina (default: 20) +- `buscar`: string - Buscar por nombre/placa +- `skip`: integer - Registros a saltar (default: 0) +- `limit`: integer - Limite de registros (default: 50, max: 100) +- `page`: integer - Pagina (alternativa a skip) +- `pageSize`: integer - Items por pagina (alternativa a limit) **Respuesta**: ```json @@ -80,29 +83,64 @@ GET /vehiculos "modelo": "T680", "ano": 2021, "tipo": "camion", - "conductor": { - "id": 1, - "nombre": "Juan Perez" - }, - "grupo": { - "id": 1, - "nombre": "Ruta Norte" - }, - "estado": "en_ruta", - "ultima_ubicacion": { - "lat": 19.4326, - "lng": -99.1332, - "velocidad": 45, - "tiempo": "2026-01-21T10:30:00Z" - } + "activo": true, + "en_servicio": true } ], "total": 12, "page": 1, - "per_page": 20 + "pageSize": 50 } ``` +### Listar Todos los Vehiculos (Sin paginacion) + +```http +GET /vehiculos/all +``` + +Retorna todos los vehiculos activos sin paginacion. Util para mapas y selectores. + +**Respuesta**: +```json +[ + { + "id": 1, + "nombre": "Camion-01", + "placa": "ABC-123", + "activo": true + } +] +``` + +### Estadisticas de Flota + +```http +GET /vehiculos/fleet/stats +``` + +**Respuesta**: +```json +{ + "total": 12, + "activos": 10, + "inactivos": 2, + "mantenimiento": 1, + "enMovimiento": 5, + "detenidos": 4, + "sinSenal": 1, + "alertasActivas": 3 +} +``` + +### Ubicaciones Actuales + +```http +GET /vehiculos/ubicaciones/actuales +``` + +Retorna las ubicaciones actuales de todos los vehiculos. + ### Obtener Vehiculo ```http @@ -186,12 +224,34 @@ GET /vehiculos/{id}/historial ## Conductores -### Listar Conductores +### Listar Conductores (Paginado) ```http GET /conductores ``` +**Parametros query**: +- `activo`: boolean - Filtrar por activos +- `buscar`: string - Buscar por nombre, apellido o licencia +- `skip`: integer - Registros a saltar +- `limit`: integer - Limite de registros + +### Listar Todos los Conductores + +```http +GET /conductores/all +``` + +Retorna todos los conductores activos. + +### Listar Conductores Disponibles + +```http +GET /conductores/disponibles +``` + +Retorna conductores activos sin vehiculo asignado. + ### Crear Conductor ```http @@ -292,9 +352,34 @@ GET /viajes **Parametros query**: - `vehiculo_id`: integer - `conductor_id`: integer +- `estado`: string - "en_curso", "completado" - `desde`: datetime - `hasta`: datetime -- `estado`: string - "en_curso", "completado" +- `skip`: integer +- `limit`: integer + +### Listar Viajes Activos + +```http +GET /viajes/activos +``` + +Retorna viajes actualmente en curso. + +### Iniciar Viaje Manual + +```http +POST /viajes/iniciar +Content-Type: application/json + +{ + "vehiculo_id": 1, + "conductor_id": 1, + "proposito": "Entrega a cliente", + "lat": 19.4326, + "lng": -99.1332 +} +``` ### Obtener Viaje @@ -378,12 +463,12 @@ GET /alertas ``` **Parametros query**: -- `atendida`: boolean -- `severidad`: string - "info", "media", "critica" -- `tipo`: string -- `vehiculo_id`: integer -- `desde`: datetime -- `hasta`: datetime +- `vehiculo_id`: integer - Filtrar por vehiculo +- `tipo_alerta_id`: integer - Filtrar por tipo +- `severidad`: string - "baja", "media", "alta", "critica" +- `atendida`: boolean - Filtrar por estado +- `desde`: datetime - Fecha inicio +- `hasta`: datetime - Fecha fin ### Obtener Alertas Pendientes @@ -391,6 +476,53 @@ GET /alertas GET /alertas/pendientes ``` +### Obtener Estadisticas + +```http +GET /alertas/estadisticas +``` + +### Obtener Configuracion de Alertas + +```http +GET /alertas/configuracion +``` + +**Respuesta**: +```json +{ + "tipos": [ + { + "id": 1, + "codigo": "EXCESO_VELOCIDAD", + "nombre": "Exceso de Velocidad", + "severidad_default": "media", + "activo": true, + "notificar_email": true, + "notificar_push": true, + "notificar_sms": false + } + ], + "notificaciones": { + "email_habilitado": true, + "push_habilitado": true, + "sms_habilitado": false + } +} +``` + +### Actualizar Configuracion de Alertas + +```http +PUT /alertas/configuracion +``` + +### Listar Tipos de Alerta + +```http +GET /alertas/tipos +``` + ### Marcar como Atendida ```http @@ -406,12 +538,45 @@ Content-Type: application/json ## Geocercas -### Listar Geocercas +### Listar Geocercas (Paginado) ```http GET /geocercas ``` +**Parametros query**: +- `activa`: boolean - Filtrar por activas +- `tipo`: string - Filtrar por tipo (circular/poligono) +- `categoria`: string - Filtrar por categoria + +### Listar Todas las Geocercas + +```http +GET /geocercas/all +``` + +Retorna todas las geocercas activas sin paginacion. + +### Obtener Geocercas en GeoJSON + +```http +GET /geocercas/geojson +``` + +Retorna todas las geocercas en formato GeoJSON FeatureCollection. + +### Crear Geocerca Circular + +```http +POST /geocercas/circular +``` + +### Crear Geocerca Poligonal + +```http +POST /geocercas/poligono +``` + ### Crear Geocerca ```http @@ -583,6 +748,60 @@ Content-Type: application/json ## Reportes +### Estadisticas de Reportes + +```http +GET /reportes/stats +``` + +### Plantillas Disponibles + +```http +GET /reportes/templates +``` + +**Respuesta**: +```json +[ + {"id": "viajes", "nombre": "Reporte de Viajes", "descripcion": "Detalle de viajes realizados"}, + {"id": "alertas", "nombre": "Reporte de Alertas", "descripcion": "Resumen de alertas generadas"}, + {"id": "combustible", "nombre": "Reporte de Combustible", "descripcion": "Consumo y cargas de combustible"}, + {"id": "mantenimiento", "nombre": "Reporte de Mantenimiento", "descripcion": "Estado de mantenimientos"} +] +``` + +### Previsualizar Reporte + +```http +POST /reportes/preview +Content-Type: application/json + +{ + "tipo": "viajes", + "fecha_inicio": "2026-01-01", + "fecha_fin": "2026-01-25" +} +``` + +### Reportes Programados + +```http +GET /reportes/programados +``` + +### Programar Reporte + +```http +POST /reportes/programar +Content-Type: application/json + +{ + "tipo": "viajes", + "frecuencia": "semanal", + "email_destino": "admin@atlas.com" +} +``` + ### Obtener Datos de Dashboard ```http @@ -644,6 +863,76 @@ GET /reportes/{id}/descargar --- +## POIs (Puntos de Interes) + +### Listar POIs + +```http +GET /pois +``` + +**Parametros query**: +- `categoria`: string - Filtrar por categoria +- `activo`: boolean - Filtrar por activos + +### Listar Todos los POIs + +```http +GET /pois/all +``` + +### Crear POI + +```http +POST /pois +Content-Type: application/json + +{ + "nombre": "Cliente ABC", + "categoria": "cliente", + "latitud": 19.4326, + "longitud": -99.1332, + "direccion": "Av. Insurgentes 123" +} +``` + +--- + +## Configuracion del Sistema + +### Obtener Configuracion + +```http +GET /configuracion +``` + +**Respuesta**: +```json +{ + "nombre_empresa": "Atlas GPS", + "timezone": "America/Mexico_City", + "unidad_distancia": "km", + "unidad_velocidad": "km/h", + "limite_velocidad_default": 120, + "alerta_bateria_baja": 20, + "alerta_sin_senal_minutos": 30 +} +``` + +### Actualizar Configuracion + +```http +PATCH /configuracion +Content-Type: application/json + +{ + "nombre_empresa": "Mi Empresa GPS", + "limite_velocidad_default": 100 +} +``` + +--- + ## WebSocket ### Conexion