Cart
Get All Cart
You can access the list more then 10 carts by using the /carts endpoint
Request:
 [GET] http://fake-shop-api.ap-south-1.elasticbeanstalk.com/app/v1/carts
Response:
{
  "status": "success",
  "count": 1,
  "Data": [
    {
      "userId": "64c9e431b3a6a1915d40f099",
      "items": [
        {
          "productId": "64c9dab8e1ffe09097e0b849",
          "name": "Angelfish",
          "price": 100,
          "quantity": 1,
          "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg"
        },
        {
          "productId": "64c9dab8e1ffe09097e0b844",
          "name": "Angelfish 2",
          "price": 1000,
          "quantity": 3,
          "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg"
        }
      ],
      "total": 1120,
      "__v": 0
    }
  ]
}
Get Cart By User Id
You can get the cart of user by using the /carts/<userId> endpoint.
Request:
 [GET] http://fake-shop-api.ap-south-1.elasticbeanstalk.com/app/v1/carts/64c9e431b3a6a1915d40f099
Response:
{
  "status": "success",
  "count": 1,
  "Data": [
    {
      "userId": "64c9e431b3a6a1915d40f099",
      "items": [
        {
          "productId": "64c9dab8e1ffe09097e0b849",
          "name": "Angelfish",
          "price": 100,
          "quantity": 1,
          "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg"
        },
        {
          "productId": "64c9dab8e1ffe09097e0b844",
          "name": "Angelfish 2",
          "price": 1000,
          "quantity": 3,
          "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg"
        }
      ],
      "total": 1120,
      "__v": 0
    }
  ]
}
Add Cart
You can add item and create cart by using the /carts/userId endpoint. And passing cart data as JSON in body.
NOTE: It will increase quantity in cart if the item already exist in cart, if not it will add new item in cart.
Request:
 [POST] http://fake-shop-api.ap-south-1.elasticbeanstalk.com/app/v1/carts/64c9e431b3a6a1915d40f099
Body:
{
  "item": {
    "productId": "64c9dab8e1ffe09097e0b844",
    "name": "Angelfish 3",
    "quantity": 1,
    "price": 10,
    "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg"
  }
}
Response:
{
  "status": "success",
  "data": {
    "_id": "64d84950e7da17a39d156a73",
    "userId": "64c9e431b3a6a1915d40f099",
    "items": [
      {
        "productId": "64c9dab8e1ffe09097e0b849",
        "name": "Angelfish",
        "price": 100,
        "quantity": 1,
        "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg",
        "_id": "64d84950e7da17a39d156a74"
      },
      {
        "productId": "64c9dab8e1ffe09097e0b844",
        "name": "Angelfish 2",
        "price": 1000,
        "quantity": 4,
        "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg",
        "_id": "64d8496ce7da17a39d156a7a"
      }
    ],
    "total": 1130,
    "__v": 0
  }
}
Update Cart
You can update cart (increase quantity of item, update name, update image ) by using the /carts/userId endpoint. And passing cart data as JSON in body.

NOTE: You have to pass productId also in body to update cart item, it will not work if productId is not passed.
Request:
 [PATCH] http://fake-shop-api.ap-south-1.elasticbeanstalk.com/app/v1/carts/64c9e431b3a6a1915d40f099
Body:
{
  "item": {
    "productId": "64c9dab8e1ffe09097e0b849",
    "name": "Angel",
    "quantity": 1,
    "price": 1100,
    "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg"
  }
}
Response:
{
  "status": "success",
  "data": {
    "_id": "64d84950e7da17a39d156a73",
    "userId": "64c9e431b3a6a1915d40f099",
    "items": [
      {
        "productId": "64c9dab8e1ffe09097e0b849",
        "name": "Angel",
        "price": 1100,
        "quantity": 1,
        "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg",
        "_id": "64d84950e7da17a39d156a74"
      },
      {
        "productId": "64c9dab8e1ffe09097e0b844",
        "name": "Angelfish 2",
        "price": 1000,
        "quantity": 4,
        "image": "http://img6a.flixcart.com/image/pouch-potli/u/x/v/aelkabj01224-a-angelfish-potli-silk-potali-original-imaeeprygdj223es.jpeg",
        "_id": "64d8496ce7da17a39d156a7a"
      }
    ],
    "total": 5100,
    "__v": 0
  }
}
Delete Item
You can delete item from cart by using the /carts/<userId>/<productId> endpoint.
Request:
 [DELETE] http://fake-shop-api.ap-south-1.elasticbeanstalk.com/app/v1/carts/64c9e431b3a6a1915d40f099/64c9dab8e1ffe09097e0b849
Response:
{
  "status": "success"
}
Delete Cart
You can delete cartt by using the /carts/<userId> endpoint.

NOTE: You not able to delete all cart , to delete you have to create your own cart.
Request:
 [DELETE] http://fake-shop-api.ap-south-1.elasticbeanstalk.com/app/v1/carts/64c9e431b3a6a1915d40f099
Response:
{
  "status": "success"
}