online shop
=====================
This is a small online shop where we Handle stocks for availability
In an online shop we would provide all available products the stock data. Additionally for analytic reasons, we also want to keep track on some basic statistics.
This application is build using latest version of spring boot , Java 8
The provided end points :
- POST /updateStock
- GET /stock?productId=p23
- GET /statistics?time=[today,lastMonth]
- To post new record timestamp is not required in the request
- In case you want to update exsiting stock , then you should provide the latest timastamp which we can have from the GET request result , and if you do provide the correct timestamp the request will fail with status code 204
- If the new quantity is less than the old one , it is considerd as sale
- As I said in my email I see that sending the stock change is much better and will simplify the task 5- The application is not perfect yet , there are some points which I did not fix yet , like exceptions handling
First clone the project, if not already done so.
mvn clean
mvn insatll
run the applicatio using
mvn spring-boot:run
Example:
- POST /updateStock
{
"id":"000001",
"timestamp":"2017-10-12T13:19:36.556Z",
"productId" : "p23",
"quantity":18
}
- GET /stock?productId=p23
- GET /statistics?time=lastMonth
- GET /statistics?time=today
This Application has a lot of test cases , To run them run the following command in the root directory , but most of them are intergration tests .
mvn test