Saltar al contenido principal

Shifts

Gestión de Turnos

Los endpoints de turnos permiten administrar los horarios de trabajo del personal del restaurante.

  • GET /shifts: Obtiene todos los turnos del sistema.

    • cURL Example:
    curl -X GET "http://127.0.0.1:9154/shifts" \
    -H 'Cookie: accessToken=your_access_token_here' \
    -H 'Cookie: refreshToken=your_refresh_token_here'
    • Response Body (Éxito - 200 OK):
    [
    {
    "id": "670ee547-bc75-4c02-89ff-2cd45f12c77f",
    "user_id": "f9c9d4fc-c4b7-4c42-8ae3-bb4649b34f2b",
    "shift_date": "1753523565371",
    "start_time": "1753523565371",
    "end_time": "1753549837824",
    "notes": "Turno de mañana"
    },
    {
    "id": "c145e48c-210e-49fd-b2fd-3b8fbaf76529",
    "user_id": "b3ddbf81-7934-49ed-b495-086f8c5eda93",
    "shift_date": "1753523565371",
    "start_time": "1753523565371",
    "end_time": null,
    "notes": "Turno de tarde - En curso"
    }
    ]
    • Response Body (Sin contenido - 204 No Content):
    "No shifts found"
  • GET /shifts/{id}: Obtiene un turno específico por su ID.

    • Authorization: Requiere access token válido (enviado automáticamente via cookies)
    • Path Parameters:
      • id (string): ID del turno a obtener
    • cURL Example:
    curl -X GET "http://127.0.0.1:9154/shifts/0e5805f1-ff25-4c9d-823b-cacc81eb31db" \
    -H 'Cookie: accessToken=your_access_token_here' \
    -H 'Cokkie: refreshToken=your_refresh_token_here'
    • Response Body (Éxito - 200 OK):
    {
    "id": "0e5805f1-ff25-4c9d-823b-cacc81eb31db",
    "user_id": "ac5f7527-3c9a-4d89-9133-ee5d8fde631e",
    "shift_date": "1753523565371",
    "start_time": "1753523565371",
    "end_time": "1753549837824",
    "notes": "Turno de mañana"
    }
    • Response Body (Error - 400 Bad Request):
    "Missing or malformed ID"
    • Response Body (Error - 404 Not Found):
    "Shift not found"
  • POST /shifts: Crea un nuevo turno.

    • Authorization: Requiere access token válido (enviado automáticamente via cookies)
    • Request Body:
    {
    "user_id": "string",
    "shift_date": "Unix Timestamp",
    "start_time": "Unix Timestamp ",
    "end_time": "Unix Timestamp ",
    "notes": "string"
    }
    • cURL Example:
    curl -X POST "http://127.0.0.1:9154/shifts" \
    -H 'Cookie: accessToken=your_access_token_here' \
    -H 'Cokkie: refreshToken=your_refresh_token_here' \
    -H "Content-Type: application/json" \
    -d '{
    "id": "0e5805f1-ff25-4c9d-823b-cacc81eb31db",
    "user_id": "ac5f7527-3c9a-4d89-9133-ee5d8fde631e",
    "shift_date": "1753523565371",
    "start_time": "1753523565371",
    "end_time": "1753549837824",
    "notes": "Turno de mañana"
    }'
    • Response Body (Éxito - 201 Created):
  • PUT /shifts/{id}: Actualiza un turno existente.

    • Authorization: Requiere access token válido (enviado automáticamente via cookies)
    • Path Parameters:
      • id (string): ID del turno a actualizar
    • Request Body:
    {
    "user_id": "string",
    "shift_date": "Unix Timestamp",
    "start_time": "Unix Timestamp ",
    "end_time": "Unix Timestamp ",
    "notes": "string"
    }
    • cURL Example:
    curl -X PUT "http://127.0.0.1:9154/shifts/0e5805f1-ff25-4c9d-823b-cacc81eb31db" \
    -H 'Cookie: accessToken=your_access_token_here' \
    -H 'Cokkie: refreshToken=your_refresh_token_here' \
    -H "Content-Type: application/json" \
    -d '{
    "user_id": "03978988-42ff-4cb9-a790-c51aceb39b2b",
    "shift_date": "1753523565371",
    "start_time": "1753523565371",
    "end_time": "1753549837824",
    "notes": "Turno extendido por eventos especiales"
    }'
    • Response Body (Éxito - 200 OK):
    "Shift updated successfully"
    • Response Body (Error - 400 Bad Request):
    "Missing or malformed ID"
    • Response Body (Error - 404 Not Found):
    "Shift not found"
  • DELETE /shifts/{id}: Elimina un turno del sistema.

    • Authorization: Requiere access token válido (enviado automáticamente via cookies)
    • Path Parameters:
      • id (string): ID del turno a eliminar
    • cURL Example:
    curl -X DELETE "http://127.0.0.1:9154/shifts/03978988-42ff-4cb9-a790-c51aceb39b2b" \
    -H 'Cookie: accessToken=your_access_token_here' \
    -H 'Cokkie: refreshToken=your_refresh_token_here' \
    • Response Body (Éxito - 200 OK):
    "Shift deleted successfully"
    • Response Body (Error - 400 Bad Request):
    "Missing or malformed ID"
    • Response Body (Error - 404 Not Found):
    "Shift not found"

Notas importantes:

  • Todos los endpoints de turnos requieren autenticación a excepción del GET, que es requerido al iniciar sessión
  • Los IDs de turnos son UUID generados automáticamente
  • Un turno debe estar asociado a un usuario válido (user_id)
  • El campo end_time puede ser null para turnos en curso
  • El campo notes es opcional y puede contener información adicional
  • No puede haber turnos solapados para el mismo usuario en la misma fecha