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
GETproduct-type returns all product-types
GETproduct-type/:id returns the product-type matching requested ID
POSTproduct-type{ "title": [new-product-type] } adds that product type to the database
PUTproduct-type/:id{ "title": [new-title] } edits the title for the product type matching requested ID
DELETEproduct-type/:id deletes the product type matching that ID
Steps to Test Solution
(optional) Reset DB: npm run db:generate
Comment out all paths other than product-types
npm start
GETlocalhost:8080/api/v1/product-type should return all data in Product_Types, confirm by searching DB in db browser with SELECT * FROM Product_Types
GETlocalhost:8080/api/v1/product-type/4 should return `{ "product_type_id": 4, "title": "Health" }
POSTlocalhost:8080/api/v1/product-type with this payload:
{
"title": "Furniture"
}
Should return: 10 (new ID)
PUTlocalhost: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
DELETElocalhost: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
Description
Users can make requests to
GET
,POST
,PUT
, &DELETE
data forProduct_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
, androutes/products/product-types
, requests toGET
,POST
,PUT
, &DELETE
are correctly handled, returning appropriate data to the user inJSON
formatExpected Behavior
GET
product-type
returns all product-typesGET
product-type/:id
returns the product-type matching requested IDPOST
product-type
{ "title": [new-product-type] }
adds that product type to the databasePUT
product-type/:id
{ "title": [new-title] }
edits the title for the product type matching requested IDDELETE
product-type/:id
deletes the product type matching that IDSteps to Test Solution
(optional) Reset DB:
npm run db:generate
Comment out all paths other than
product-types
npm start
GET
localhost:8080/api/v1/product-type
should return all data inProduct_Types
, confirm by searching DB in db browser withSELECT * FROM Product_Types
GET
localhost:8080/api/v1/product-type/4
should return `{ "product_type_id": 4, "title": "Health" }POST
localhost:8080/api/v1/product-type
with this payload:Should return:
10
(new ID)PUT
localhost:8080/api/v1/product-type/7
with this payload:Should return:
7
Run:localhost:8080/api/v1/product-type/7
to confirmtitle
changed toThe Good Stuff
DELETE
localhost:8080/api/v1/product-type/3
should return:1
Run:localhost:8080/api/v1/product-type/3
to confirm nothing is returnedTesting
[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