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

Fixes #5: GET, POST, PUT, & DELETE for Product_Types #104

Closed DavidLarsKetch closed 6 years ago

DavidLarsKetch commented 6 years ago

Description

Users can make requests to GET, POST, PUT, & DELETE data for Product_Types

Number of Fixes

1

Related Ticket(s)

Fixes #5, follows reqs in #103

Problem to Solve

Users were not able to interact with the data stored Product_Types

Proposed Changes

Using ProductTypesModel, productTypesCtrl, and routes/products/product-types, requests to GET, POST, PUT, & DELETE are correctly handled, returning appropriate data to the user in JSON format

Expected Behavior

GET product-type returns all product-types

GET product-type/:id returns the product-type matching requested ID

POST product-type { "title": [new-product-type] } adds that product type to the database

PUT product-type/:id { "title": [new-title] } edits the title for the product type matching requested ID

DELETE product-type/:id deletes the product type matching that ID

Steps to Test Solution

  1. (optional) Reset DB: npm run db:generate

  2. Comment out all paths other than product-types

  3. npm start

  4. GET localhost:8080/api/v1/product-type should return all data in Product_Types, confirm by searching DB in db browser with SELECT * FROM Product_Types

  5. GET localhost:8080/api/v1/product-type/4 should return `{ "product_type_id": 4, "title": "Health" }

  6. POST localhost:8080/api/v1/product-type with this payload:

    {
    "title": "Furniture"
    }

    Should return: 10 (new ID)

  7. PUT localhost:8080/api/v1/product-type/7 with this payload:

    {
    "title": "The Good Stuff"
    }

    Should return: 7 Run: localhost:8080/api/v1/product-type/7 to confirm title changed to The Good Stuff

  8. DELETE localhost:8080/api/v1/product-type/3 should return: 1 Run: localhost:8080/api/v1/product-type/3 to confirm nothing is returned

Testing

[x] There are new unit tests in this PR, and I verify that there is full coverage of all new code. [x] I certify that all existing tests pass

DavidLarsKetch commented 6 years ago

Alright should be fixed up! Thanks for catching that @kenziebottoms