POST /api/v1/books/cart
Description
This endpoint allows developers to insert new books cart to the database by passing a cart object in the request. The cart object must contain the fields "total", for the total price in the cart, "volume", for the number of books in the cart, and "books", a list of books in the cart, each book is a book object with id and the quantity. For each book, the value quantity field is added to the "amount_sold" field in the book.
Body (raw)
A json object containing the following items.
total: Total price of the cart (float).volume: Total amount of books in the cart(int).books: List of the books in the cart. Each index is a book object containing its id and quantity in the cart.
Request
Response
The response will show if the books were added successfully.
{
"status": "Success",
"message": "Books added successfully"
}Bad Request (400)
If one of the required fields is missing
{
"code": "400",
"status": "Bad Request",
"message": "The shopping cart must contain 'total , 'volume' and 'total'"
}If the total value isn't numeric
{
"code": "400",
"status": "Bad Request",
"message": "The total value must be numeric"
}If the volume value isn't an integer
{
"code": "400",
"status": "Bad Request",
"message": "The number of books (volume) must be an integer"
}If the value passed in the books field isn't a list
{
"code": "400",
"status": "Bad Request",
"message": "The books in the cart must be in a list"
}If a book passed in the books list don't exists in the database
{
"code": "400",
"status": "Bad Request",
"message": "The book with the id "<id>", don't exists."
}If a book passed in the books list don't have the id field
{
"code": "400",
"status": "Bad Request",
"message": "Couldn't find the book's id"
}If a book passed in the books list don't have the quantity field
{
"code": "400",
"status": "Bad Request",
"message": "Couldn't find the book's quantity"
}