This microservice provides REST API endpoints for an inventory, and integrates with the PostgreSQL database.
Add a new product to the inventory.
A JSON object containing
pid(a number referring to the id of a product)pcode(a unique code identifying the product)price(the price of the product)sku(the stock keeping unit of the product)amount_in_stock(quantity of the product in the stock)pname(name of the product)description(description of the product)lang(language of the details of the product)
Example:
{
"pid": 1,
"pcode": "ABC",
"price": 10,
"sku": "XYZ123",
"amount_in_stock": 100,
"pname": "Name",
"description": "Description",
"lang": "en_US"
}Status code: 201.
Body: a JSON object containing
data: on a successful request, an array containing elements with:pid: id of the updated productpname: name of the updated productdescription: description of the product
Example:
{
"data": [
{
"pid": 1,
"pname": "Name",
"description": "Description"
}
]
}Errors:
- 400: bad request (e.g. empty request body, or product already present)
Update a product in the inventory.
A JSON object containing
pid(a number referring to the id of a product)pcode(a unique code identifying the product)price(the price of the product)sku(the stock keeping unit of the product)amount_in_stock(quantity of the product in the stock)pname(name of the product)description(description of the product)lang(language of the details of the product)
Example:
{
"pid": 1,
"pcode": "ABC",
"price": 10,
"sku": "XYZ123",
"amount_in_stock": 100,
"pname": "Name",
"description": "Description",
"lang": "en_US"
}Status code: 200.
Body: a JSON object containing
message: a message regarding the status of the requestdata: on a successful request, an array containing elements with:pid: id of the added productpname: name of the added productdescription: description of the product
Example:
{
"message": "Product updated.",
"data": [
{
"pid": 1,
"pname": "Name",
"description": "Description"
}
]
}Errors:
- 400: bad request (e.g. empty request body, or wrong product ID)
List the product with a given ID in the inventory.
Empty.
Status code: 200.
Body: a JSON object containing
data: on a successful request, an array containing elements with:products: details of the product
Example:
{
"data": [
{
"products": "(2,3a,10,abc_sku,10,jaguar,\"my jaguar\",english)"
}
]
}Errors:
- 400: bad request (e.g. product not found)
List all products in the inventory.
Empty.
Status code: 200.
Body: a JSON object containing
data: on a successful request, an array containing elements with:products: details of the products
Example:
{
"data": [
{
"products": "(2,3a,10,abc_sku,10,jaguar,\"my jaguar\",english)"
}
]
}Delete a product from the inventory
None.
Status code: 200.
Body: a JSON object containing
message: a message regarding the status of the requestdata: number of elements deleted
Example:
{
"message": "Product deleted.",
"data": 1
}Errors:
- 400: bad request (e.g. product does not exist)
Remove {amount} of product from the inventory.
None.
Status code: 200.
Body: a JSON object containing
message: a message regarding the status of the requestdata: JSON object of the modified product, containingamount_in_stockpid
Example:
{
"message": "Amount subtracted",
"data": {
"amount_in_stock": 120,
"pid": 1
}
}Errors:
- 400: bad request (e.g. not enough in stock)
Add {amount} of product to the inventory.
None.
Status code: 200.
Body: a JSON object containing
message: a message regarding the status of the requestdata: JSON object of the modified product, containingamount_in_stockpid
Example:
{
"message": "Amount added",
"data": {
"amount_in_stock": 125,
"pid": 1
}`
}