3. Cart API Specification - Gluzberg/cart-api GitHub Wiki
All of the below calls require a Bearer Token produced Token API.
Retrieve Cart information by given ID
-
URL
/cart/:id
-
Method:
GET
-
URL Params
Required:
id=[Guid]
-
Data Params
None
-
Success Response:
-
Code:
200 OK
Content:{ id : Guid, products: []" }
-
Code:
-
Error Response:
-
Code:
401 UNAUTHORIZED
-
Code:
400 BAD REQUEST
Content:{ "message": "Cart with the specified ID does not exist" }
-
-
Sample Call:
GET /api/cart/77107471-b9a9-4825-be91-9529e73845e2 HTTP/1.1 Content-Type: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
-
Notes:
- Only products specified in the requests would be added or updated if they already exist in the cart.
- Products with non-positive amount would be then deleted from the cart.
Creating new Cart with given ID
-
URL
/cart/:id
-
Method:
POST
-
URL Params
Required:
id=[Guid]
-
Data Params
None
-
Success Response:
-
Code:
200 OK
Content:{ id : Guid, products: []" }
-
Code:
-
Error Response:
-
Code:
401 UNAUTHORIZED
-
Code:
400 BAD REQUEST
Content:{ "message": "Cart with the specified ID already exist" }
-
Code:
400 BAD REQUEST
Content:{ "message": "Data storage error had occurred" }
-
-
Sample Call:
POST /api/cart/77107471-b9a9-4825-be91-9529e73845e2 HTTP/1.1 Content-Type: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Update a Cart by given ID with specified products list.
-
URL
/put/
-
Method:
PUT
-
URL Params
None
-
Data Params
Required:
{ "cartid" : Guid, "products": [ { "productid" : Guid, "amount" : uint } ] }
-
Success Response:
-
Code:
200 OK
Content:{ id : Guid, products: []" }
-
Code:
-
Error Response:
-
Code:
401 UNAUTHORIZED
-
Code:
400 BAD REQUEST
Content:{ "message": "Cart with the specified ID does not exist" }
-
Code:
400 BAD REQUEST
Content:{ "message": "Data storage error had occurred" }
-
-
Sample Call:
PUT /api/cart Content-Type: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... { "cartid" : "70107471-b9a9-4825-be91-9529e73845e2", "products": [ { "productid" : "c4f4026b-719e-499d-9563-1afdefdeb5b7", "amount" : 7 } , { "productid" : "c4f4026b-719e-499d-9563-1afdefdeb5b1", "amount" : 12 } ] }
Delete a Cart by given ID
-
URL
/delete/:id
-
Method:
DELETE
-
URL Params
Required:
id=[Guid]
-
Data Params
None
-
Success Response:
-
Code:
200 OK
Content:{ id : Guid, products: []" }
-
Code:
-
Error Response:
-
Code:
401 UNAUTHORIZED
-
Code:
400 BAD REQUEST
Content:{ "message": "Cart with the specified ID does not exist" }
-
Code:
400 BAD REQUEST
Content:{ "message": "Data storage error had occurred" }
-
-
Sample Call:
DELETE /api/cart/77107471-b9a9-4825-be91-9529e73845e2 HTTP/1.1 Content-Type: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...