- Endpoint:
GET /api/v1/orders/{orderId}
- Description: Get details for a specific order.
- Status Code: 200 OK
- Body:
{
"orderId": 1001,
"user": {
"userId": 2,
"userName": "Jane Smith",
"email": "jane@example.com",
"address": "456 Oak Ave"
},
"products": [
{
"productId": 108,
"productName": "Product H",
"price": 69.99,
"name": "Description for Product H"
},
//... other orders
],
"orderDate": 20231213,
"quantity": 3,
"totalAmount": 12.23
}
- Endpoint:
POST /api/v1/orders
- Description: Create a new order
{
"userId": 3,
"productIds": [2003, 2004],
"orderDate": 20220122,
"quantity": 3,
"totalAmount": 89.97
}
- Status Code: 201 CREATED
- Body:
{
"orderId": 1001,
"user": {
"userId": 3,
"userName": "Jane Smith",
"email": "jane@example.com",
"address": "456 Oak Ave"
},
"products": [
{
"productId": 2003,
"productName": "Product H",
"price": 69.99,
"name": "Description for Product H"
},
{
"productId": 2004,
"productName": "Product K",
"price": 69.99,
"name": "Description for Product H"
}
],
"orderDate": 20231213,
"quantity": 3,
"totalAmount": 89.97
}
- Endpoint:
PUT /api/v1/orders/{orderId}
- Description: Update an existing order.
{
"orderId": 1002,
"userId": 3,
"productIds": [2003, 2004],
"orderDate": 20220122,
"quantity": 5,
"totalAmount": 149.95
}
- Status Code: 200 OK
- Body: The updated order object
-
Endpoint:
DELETE /api/v1/orders/{orderId}
-
Description: Delete an existing order.
-
Path Parameters:
orderId
(integer, required): The ID of the order to be deleted.
- Status Code: 204 No Content
- Body: (No Content)
- Endpoint:
GET /api/v1/users/top-users
- Description: Get the top 3 users who have ordered the most products based on the count of products in their orders.
- Status Code: 200 OK
- Body:
[
{
"userId": 1,
"userName": "John Doe",
"totalOrderedProducts": 123
},
{
"userId": 2,
"userName": "Jane Smith",
"totalOrderedProducts": 121
},
{
"userId": 3,
"userName": "Alice Johnson",
"totalOrderedProducts": 120
}
]
- Endpoint:
GET /api/v1/product/top
- Description: Get the top 3 most ordered products based on the number of all orders.
- Status Code: 200 OK
- Body:
[
{
"productId": 1001,
"productName": "Product A",
"totalOrders": 25
},
{
"productId": 1002,
"productName": "Product B",
"totalOrders": 20
},
{
"productId": 1003,
"productName": "Product C",
"totalOrders": 18
}
]
- Endpoint:
GET /api/v1/products/top/reordered
- Description: Get the top 3 most reordered products based on each user's first order.
- Status Code: 200 OK
- Body:
[
{
"productId": 1001,
"productName": "Product A"
},
{
"productId": 1002,
"productName": "Product B"
},
{
"productId": 1003,
"productName": "Product C"
}
]