Giter VIP home page Giter VIP logo

cartapis's Introduction

Cart APIs

Prerequisites

  • Java 1.8
  • Maven installed

Starting the server

  1. Clone the codebase - git clone https://github.com/vikaskulkarni/cartAPIs.git
  2. Navigate to the directory cartAPIs
  3. mvn clean install -DskipTests
  4. mvn spring-boot:run

Swagger UI

http://localhost:8081/swagger-ui.html

Testing the APIs

  1. Navigate to the directory cartAPIs
  2. mvn clean test

The above command will run both Junit and Cucumber tests, so the server should be running for cucumber tests to pass

Testing APIs from Postman

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 } } ]

cartapis's People

Contributors

vikaskulkarni avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.