- Display all beverages available
- 4 Types of beverages
- Black Coffee
- Water -> 3 unit
- Coffee -> 1 unit
- Sugar -> 1 unit
- Coffee with Milk
- Water -> 1 unit
- Coffee -> 1 unit
- Milk -> 2 unit
- Sugar -> 1 unit
- Sugarfree Black Coffee
- Water -> 3 unit
- Coffee -> 1 unit
- Sugarfree Coffee with Milk
- Water -> 1 unit
- Coffee -> 1 unit
- Milk -> 2 unit
- Black Coffee
- Notify staff when it ran out of ingredients
Note : italics text are primary keys and bold are foreign keys
- Inventories
- itemId -> integer
- itemName -> varchar
- quantity -> integer
- Beverage
- beverageId -> integer
- beverageName -> varchar
- available -> boolean
- Ingredients
- beverageIngredientId -> integer (Optional)
- itemId -> Inventories.itemId
- beverageId -> Beverage.beverageId
- quantityNeeded -> integer
- Java (Spring Boot Framework)
- PostgreSQL
- Github
- Postman
- IntelliJ IDEA
- Open PostgreSQL and create Database with name
vendingmachine
- Import Queries from
Queries.sql
to your PostgreSQL - Open/Import project in InteliiJ or Eclipse
- Click on Run Application
- Open Postman For best interface for APIs.
-
URL -
http://localhost:8080/inventories/
-
Method - GET
-
Purpose - Retrieve List of all inventories supported by vending machine.
-
Parameter - NONE
-
Body Params - NONE
-
Result - List of inventories object
-
URL -
http://localhost:8080/inventories/
-
Method - POST
-
Purpose - Add new inventory to the system
-
Parameters - NONE
-
Body Params :- All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
name |
should contain name of new inventory | String | YES |
quantity |
should contain quantity inserted in the machine | Integer | YES |
- Result - Inventories object
-
URL -
http://localhost:8080/inventories/
-
Method - PUT
-
Purpose - Update existing inventory from the system
-
Parameters - NONE
-
Body Params :- All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
inventoryId |
must be a valid id of existing inventory | Integer | YES |
name |
should contain name of new inventory | String | NO |
quantity |
should contain quantity inserted in the machine | Integer | NO |
- Result - inventories object
-
URL -
http://localhost:8080/inventories/{inventoryId}
-
Method - DELETE
-
Purpose - Delete an existing inventory from the system
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
inventoryId |
must be a valid id of existing inventory | Integer | YES |
-
Body Params :- NONE
-
Result - Boolean
-
URL -
http://localhost:8080/inventories/{inventoryId}
-
Method - GET
-
Purpose - Retrieve an inventory from the system requested by given ID.
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
inventoryId |
must be a valid id of existing inventory | Integer | YES |
-
Body Params :- NONE
-
Result - inventories object
-
URL -
http://localhost:8080/inventories/increaseQuantity/{inventoryId}/{quantity}
-
Method - GET
-
Purpose - Increase the quantity of an existing inventory from the system
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
inventoryId |
must be a valid id of existing inventory | Integer | YES |
quantity |
must be a valid integer quantity | Integer | YES |
- Body Params :- NONE
- Result - inventories object
-
URL -
http://localhost:8080/inventories/checkEmpty/{inventoryId}
-
Method - GET
-
Purpose - Check whether the asked inventory is empty or not
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
inventoryId |
must be a valid id of existing inventory | Integer | YES |
- Body Params :- NONE
- Result - Boolean
-
URL -
http://localhost:8080/inventories/checkQuantity/{inventoryId}/{quantity}
-
Method - GET
-
Purpose - Check whether the asked inventory possess given quantity or not
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
inventoryId |
must be a valid id of existing inventory | Integer | YES |
quantity |
must be a valid integer quantity | Integer | YES |
- Body Params :- NONE
- Result - Boolean
-
URL -
http://localhost:8080/inventories/emptyInventories
-
Method - GET
-
Purpose - Retrieves all the inventories which are empty
-
Parameters - NONE
-
Body Params :- NONE
-
Result - List of inventories object
-
URL -
http://localhost:8080/
-
Method - POST
-
Purpose - Add new beverage to the system
-
Parameters - NONE
-
Body Params :- All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
beverageId |
must be a valid id of existing inventory | Integer | NO |
name |
should contain name of new inventory | String | YES |
available |
boolean value for availability of beverage | Boolean | NO |
- Result - Beverage object
-
URL -
http://localhost:8080/
-
Method - GET
-
Purpose - Retrieve all the beverages of the system
-
Parameters - NONE
-
Body Params :- NONE
-
Result - List of Beverage object
-
URL -
http://localhost:8080/
-
Method - PUT
-
Purpose - Update existing beverage from the system
-
Parameters - NONE
-
Body Params :- All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
beverageId |
must be a valid id of existing inventory | Integer | YES |
name |
should contain name of new inventory | String | NO |
available |
boolean value for availability of beverage | Boolean | NO |
- Result - Beverage object
-
URL -
http://localhost:8080/{beverageId}
-
Method - GET
-
Purpose - Retrieve an beverage from the system requested by given ID.
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
beverageId |
must be a valid id of existing beverage | Integer | YES |
- Result - Beverage object
- Body Params :- NONE
-
URL -
http://localhost:8080/{beverageId}
-
Method - DELETE
-
Purpose - Delete an existing beverage from the system
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
beverageId |
must be a valid id of existing beverage | Integer | YES |
- Body Params :- NONE
- Result - Boolean
-
URL -
http://localhost:8080/available/{beverageId}
-
Method - GET
-
Purpose - Retrieve all beverages which are available in the vending machine
-
Parameters - All parameters are permissible to send with request
Parameters Value Datatype Required beverageId
must be a valid id of existing beverage Integer YES -
Body Params - NONE
-
Result - Boolean
-
URL -
http://localhost:8080/available
-
Method - GET
-
Purpose - Retrieve all beverages which are available in the vending machine
-
Parameters - NONE
-
Body Params - NONE
-
Result - List of Beverage object
-
URL -
http://localhost:8080/ingredient/
-
Method - GET
-
Purpose - Retrieve all ingredients used by all beverages.
-
Parameters - NONE
-
Body Params - NONE
-
Result - List of Ingredients object
Alternative way is to call a single beverage api which will also contain information of ingredients used to create that beverage.
-
URL -
http://localhost:8080/ingredient/
-
Method - POST
-
Purpose - Insert ingredient of particular beverage.
-
Parameters - NONE
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
beverage |
Beverage object with valid beverageId under the field beverageId inside beverage object |
Integer | YES |
inventories |
Beverage object with valid inventoryId under the field inventoryId inside inventories object |
Integer | YES |
quantityRequired |
Quantity required of that inventory to create that beverage | Integer | YES |
- Result - Ingredients object
-
URL -
http://localhost:8080/ingredient/
-
Method - PUT
-
Purpose - Update ingredient of particular beverage.
-
Parameters - NONE
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
beverage |
Beverage object with valid beverageId under the field beverageId inside beverage object |
Integer | YES |
inventories |
Beverage object with valid inventoryId under the field inventoryId inside inventories object |
Integer | YES |
quantityRequired |
Quantity required of that inventory to create that beverage | Integer | YES |
- Result - Ingredients object
-
URL -
http://localhost:8080/ingredient/{ingredientId}
-
Method - GET
-
Purpose - Retrieve information of single ingredient.
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
ingredientId |
must be a valid id of existing ingredients | Integer | YES |
-
Result - Ingredients object
-
Parameters - NONE
-
URL -
http://localhost:8080/ingredient/{ingredientId}
-
Method - DELETE
-
Purpose - Delete an existing ingredient.
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
ingredientId |
must be a valid id of existing ingredients | Integer | YES |
- Parameters - NONE
- Result - Boolean
-
URL -
http://localhost:8080/order/{beverageId}
-
Method - GET
-
Purpose - Orders a beverage with valid beverageId
-
Parameters - All parameters are permissible to send with request
Parameters | Value | Datatype | Required |
---|---|---|---|
beverageId |
must be a valid id of existing beverage | Integer | YES |
-
Parameters - NONE
-
Result - Ingredients object