Completed the endpoints for /products. Added putProduct, postProduct, and deleteProduct models, controllers, and routes.
Related Ticket(s)
Completed Issue #2 (Allow developers to access product endpoints)
Expected Behavior
putProduct should insert a row if one doesn't exist at the specified id, or it should overwrite it if it does exist. If not all data is given, it will throw an error.
postProduct will insert a new product to the end of the table.
deleteProduct will delete the id passed to it.
Steps to Test Solution
Comment out employees routes and all other product routes other than product.js.
In Postman, use POST with the URL http://localhost:8080/api/v1/products/
Body:
{
"price": "199999999.99",
"title": "The Red Jewel",
"description": "A red jewel",
"product_type_id": "1",
"creator_id": "1"
}
Should return the id of the product if successful.
In Postman, use PUT with the URL http://localhost:8080/api/v1/products/50
Body:
{
"price": "199999999.99",
"title": "The Red Jewel",
"description": "A red jewel",
"product_type_id": "1",
"creator_id": "1"
}
Should return the id of the product if successful.
In Postman, use DELETE with the URL http://localhost:8080/api/v1/products/50
Should return the id of the delete value if successful.
Description
Completed the endpoints for /products. Added putProduct, postProduct, and deleteProduct models, controllers, and routes.
Related Ticket(s)
Completed Issue #2 (Allow developers to access product endpoints)
Expected Behavior
Steps to Test Solution
POST
with the URLhttp://localhost:8080/api/v1/products/
PUT
with the URLhttp://localhost:8080/api/v1/products/50
DELETE
with the URLhttp://localhost:8080/api/v1/products/50