given that one of the most interesting features of an e-commerce is the wish list, where from the product screen or product details, the user is able to add that product to their wish list.
Since because it is a microservice, the product information and user logged in will be managed by other services, this API therefore treats these entities as Id's and saves them to a Nosql bank (mongoDb) including creation date.
The API was developed using the concepts of a REST API, clean architecture, and BDD The database will run into a mongo docker container if you want to change the connection, simply change the settings in application.properties.
mvn test
docker compose up -d
mvn spring-boot:run
To see API SWAGGER doc access: http://localhost:8080/swagger-ui/
feature: Add a wish on wishlist
endpoint: /api/v1/{userId}/wishlist
method: POST
path-variable: userId must be a UUID
response-status: 201 CREATED
body:
{
"product": "4d2e1274-16ac-40b6-a6cd-9cfc0f05303d"
}
Note: the wishlist allows only 20 items per user
feature: REMOVE a item of user wishlist
endpoint: /api/v1/{userId}/wishlist/{productId}
method: DELETE
path-variable: userId must be a UUID
path-variable: productId must be a UUID
response-status: 203 NO-CONTENT
Note: invalid params should be return status 400 and error on body message.
feature: GetAll itens from a user wishlist
endpoint: /api/v1/{userId}/wishlist
method: GET
path-variable: userId must be a UUID
response-status: 200 ok
Note: A empty list will be returned when user not found.
feature: verify if a produt is present on user wishlist
endpoint: /api/v1/{userId}/wishlist/{productId}
method: GET
path-variable: userId must be a UUID
path-variable: productId must be a UUID
response-status: 200 ok
Response body sample:
{
"is-present": true
}