chicken-sloths / bangazon-api-sprint1

API for a mock Amazon + Etsy platform providing developers access to the company's employee & product data
0 stars 0 forks source link

putProduct(), postProduct(), and deleteProduct() #102

Closed TimAConner closed 6 years ago

TimAConner commented 6 years ago

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

  1. 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.
  2. postProduct will insert a new product to the end of the table.
  3. deleteProduct will delete the id passed to it.

Steps to Test Solution

  1. Comment out employees routes and all other product routes other than product.js.
  2. In Postman, use POST with the URL http://localhost:8080/api/v1/products/
    1. Body:
      {
      "price": "199999999.99",
      "title": "The Red Jewel",
      "description": "A red jewel",
      "product_type_id": "1",
      "creator_id": "1"
      }
      1. Should return the id of the product if successful.
  3. In Postman, use PUT with the URL http://localhost:8080/api/v1/products/50
    1. Body:
      {
      "price": "199999999.99",
      "title": "The Red Jewel",
      "description": "A red jewel",
      "product_type_id": "1",
      "creator_id": "1"
      }
    2. Should return the id of the product if successful.
  4. In Postman, use DELETE with the URL http://localhost:8080/api/v1/products/50
    1. Should return the id of the delete value if successful.