Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.

Latest commit

 

History

History
73 lines (56 loc) · 1.58 KB

product.md

File metadata and controls

73 lines (56 loc) · 1.58 KB

Products

The product resource has the following schema:

Field Type Description
price float The price of the product
description string the product description
name string The product name
imported bool True if te product is imported, false otherwise
category string product category one of (food, medicine, book, miscellaneous)
id uuid v4 string the product id (is autogenerated at creation time)

Product Resource endpoints and examples

Create a product

HTTP verb: POST

HTTP successful return code: 201, 400, 500

Endpoint: http://localhost:5000/products

Curl example:

curl -X POST http://localhost:5000/products -d '
{
	"name": "Bag of potato chips",
	"description": "",
	"imported": false,
	"category": "food",
	"price": 2.50
}'

Returns a product with an ID. Example:

{
    "price": 2.5,
    "description": "",
    "imported": false,
    "name": "Bag of potato chips",
    "id": "f3753db3-0521-4214-b311-d31bae67921d",
    "category": "food"
}

List all products

HTTP verb: GET

HTTP potentialc return codes: 200, 400, 500

Endpoint: http://localhost:5000/products

Curl example:

curl http://localhost:5000/products

Returns an empty list if no products are available or a list of products with their IDs

Get a single product

HTTP verb: GET

HTTP successful return code: 200, 400, 404, 500

Endpoint: http://localhost:5000/products/<product_id>

Curl example:

curl http://localhost:5000/products/f3753db3-0521-4214-b311-d31bae67921d

Returns the product if found else returns a 404 status code