- Java 1.8
- Maven installed
- Clone the codebase -
git clone https://github.com/vikaskulkarni/cartAPIs.git
- Navigate to the directory cartAPIs
mvn clean install -DskipTests
mvn spring-boot:run
http://localhost:8081/swagger-ui.html
- Navigate to the directory cartAPIs
mvn clean test
The above command will run both Junit and Cucumber tests, so the server should be running for cucumber tests to pass
POST
http://localhost:8081/cart
Optional Cart body - In this first step, the endpoint creates a new empty Cart
PATCH - add product
Copy the id from the previous response
Hit the below PATCH end point to update the cart with products
http://localhost:8081/cart/{id}
[ { "op": "add", "path": "/cartItems/0", "value": { "product": { "price": 39.99, "name": "Dove Soap" }, "quantity": 5 } } ]
PATCH - add sales tax
http://localhost:8081/cart/c220ab46-b0db-4a43-bb4a-4ec8d0482aeb
[ { "op": "replace", "path": "/salesTax", "value": 12.5 } ]
GET
Copy the id from the POST call that created the cart and hit the below end point
http://localhost:8081/cart/{id}
PATCH - add product with offer
Offer Code 2 - Buy 1 Get 2
Offer Code 3 - Buy 1 Get 50% off on second
Offer Code 4 - 20% global discount
Hit the below PATCH end point to update the cart with products
http://localhost:8081/cart/{id}
[ { "op": "add", "path": "/cartItems/0", "value": { "product": { "price": 39.99, "name": "Dove Soap" }, "quantity": 5, offerCode: 2 } } ]