/orders
🔐 Requiere autenticación JWT.
GET /api/orders
page
y limit
.verificarAutenticacion
Authorization: Bearer <token>
verificarAutenticacion
validateGetAllOrders
validateRequest
Parámetro | Tipo | Opcional | Default | Descripción |
---|---|---|---|---|
page | number | ✅ | 1 | Número de la página a obtener |
limit | number | ✅ | 10 | Cantidad de órdenes por página |
{
"status": "success",
"code": "ORDERS_FETCHED",
"msg": "Órdenes obtenidas para la página 1.",
"data": [
{
"_id": "ObjectId",
"customer": {
"Ruc": 12345678901,
"Name": "Nombre del Cliente"
},
"seller": {
"_id": "ObjectId",
"names": "Nombre del Vendedor"
},
"products": [
{
"productId": "101",
"quantity": 5,
"productDetails": {
"id": 101,
"product_name": "Producto A"
}
}
],
"discountApplied": 10,
"netTotal": 100,
"totalWithTax": 118,
"status": "Pendiente",
"registrationDate": "2025-04-24T10:00:00Z",
"lastUpdate": "2025-04-24T10:10:00Z",
"comment": "Entrega urgente",
"createdAt": "2025-04-24T10:00:00Z",
"updatedAt": "2025-04-24T10:10:00Z"
}
],
"info": {
"currentPage": 1,
"totalPages": 5,
"totalOrders": 50,
"limit": 10
}
}
{
"status": "success",
"code": "NO_ORDERS_FOUND",
"msg": "No se encontraron órdenes registradas.",
"data": [],
"info": {
"currentPage": 1,
"totalPages": 0,
"totalOrders": 0,
"limit": 10
}
}
{
"status": "error",
"code": "VALIDATION_ERROR",
"msg": "El parámetro 'page' debe ser un número entero positivo."
}
{
"status": "error",
"code": "AUTH_ERROR",
"msg": "Acceso no autorizado. Se requiere token válido."
}
{
"status": "error",
"code": "NOT_FOUND",
"msg": "Página no encontrada. Solo hay 3 páginas."
}
{
"status": "error",
"code": "SERVER_ERROR",
"msg": "Ha ocurrido un error inesperado al obtener las órdenes. Intente de nuevo más tarde.",
"info": {
"detail": "Error al conectar con la base de datos."
}
}
curl --location --request GET 'https://back-prima-s-a.onrender.com/api/orders' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3NjI0ZjkwNzY2OWM5MDZjYTM0YThkZSIsInJvbCI6ImFkbWluIiwiaWF0IjoxNzM4NjI4MjgxLCJleHAiOjE3Mzg2NTcwODF9.0or08xMGWjpppL1Lm2dGM6yX-5Y6ozETnKFwpXPgxxE'
{}