Distribute Products
Triggers the product distribution algorithm to assign warehouse stock to stores based on demand and optimization criteria.
Response
Returns an array of stock assignment objects created by the distribution algorithm.
Unique identifier for the stock assignment (UUID)
ID of the store receiving the stock
ID of the warehouse supplying the stock
ID of the product being assigned
Size of the product being assigned
Distance in kilometers between warehouse and store
Example Request
curl -X POST http://localhost:8080/api/stock-assignments/distribute
Example Response
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"storeId": "STORE001",
"warehouseId": "WH001",
"productId": "PROD001",
"size": "M",
"quantity": 50,
"distanceKm": 12.5
},
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"storeId": "STORE002",
"warehouseId": "WH001",
"productId": "PROD002",
"size": "L",
"quantity": 30,
"distanceKm": 8.3
}
]
Get All Assignments
Retrieves stock assignments with optional filtering criteria.
Query Parameters
Filter assignments by store ID
Filter assignments by warehouse ID
Filter assignments by product ID
Response
Returns an array of stock assignment objects matching the criteria.
Unique identifier for the stock assignment (UUID)
ID of the store receiving the stock
ID of the warehouse supplying the stock
ID of the product being assigned
Size of the product being assigned
Distance in kilometers between warehouse and store
Example Request
curl -X GET "http://localhost:8080/api/stock-assignments?storeId=STORE001"
Example Response
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"storeId": "STORE001",
"warehouseId": "WH001",
"productId": "PROD001",
"size": "M",
"quantity": 50,
"distanceKm": 12.5
}
]
Get Assignments By Store
Retrieves all stock assignments for a specific store.
Path Parameters
The unique identifier of the store
Response
Returns an array of stock assignment objects for the specified store.
Example Request
curl -X GET http://localhost:8080/api/stock-assignments/stores/STORE001
Example Response
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"storeId": "STORE001",
"warehouseId": "WH001",
"productId": "PROD001",
"size": "M",
"quantity": 50,
"distanceKm": 12.5
}
]
Get Assignments By Product
Retrieves all stock assignments for a specific product.
Path Parameters
The unique identifier of the product
Response
Returns an array of stock assignment objects for the specified product.
Example Request
curl -X GET http://localhost:8080/api/stock-assignments/products/PROD001
Example Response
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"storeId": "STORE001",
"warehouseId": "WH001",
"productId": "PROD001",
"size": "M",
"quantity": 50,
"distanceKm": 12.5
},
{
"id": "550e8400-e29b-41d4-a716-446655440002",
"storeId": "STORE003",
"warehouseId": "WH002",
"productId": "PROD001",
"size": "L",
"quantity": 40,
"distanceKm": 15.2
}
]
Get Assignments By Warehouse
Retrieves all stock assignments from a specific warehouse.
Path Parameters
The unique identifier of the warehouse
Response
Returns an array of stock assignment objects for the specified warehouse.
Example Request
curl -X GET http://localhost:8080/api/stock-assignments/warehouses/WH001
Example Response
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"storeId": "STORE001",
"warehouseId": "WH001",
"productId": "PROD001",
"size": "M",
"quantity": 50,
"distanceKm": 12.5
},
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"storeId": "STORE002",
"warehouseId": "WH001",
"productId": "PROD002",
"size": "L",
"quantity": 30,
"distanceKm": 8.3
}
]
Error Responses
Resource Not Found (404)
Returned when the requested store, warehouse, or product ID does not exist.
{
"error": "Resource not found",
"message": "Store with ID STORE001 does not exist"
}
Distribution Failed (500)
Returned when the distribution algorithm encounters an error.
{
"error": "Distribution failed",
"message": "Unable to complete product distribution due to system error"
}