This is a simple vending machine implemented in Java with Spring.
For building and running the application you need:
- Clone the repository.
- Navigate to the project directory.
- There are several ways to run a Spring Boot application on your local machine. One way is to execute the
main
method in thecom.martin.vending.VendingApplication
class from your IDE.
./mvnw clean install
Navigate to the project target
directory.
java -jar vending-0.0.1-SNAPSHOT.jar
POST http://localhost:8080/api/v1/vending
Content-Type: application/json
{
"name": "Cola",
"type": "snacks",
"location": "A7",
"cost": 1.50
}
PUT http://localhost:8080/api/v1/vending/4?name=ColaLight&type=drinks&location=A8&cost=1.60
Content-Type: application/json
DELETE http://localhost:8080/api/v1/vending/1
POST http://localhost:8080/purchaseProduct
Content-Type: application/json
{
"insertedCoins": [
{
"value": 0.50,
"weight": 5.0,
"diameter": 22.5
},
{
"value": 1.00,
"weight":7.0,
"diameter": 24.5
}
],
"productLocation": "A1"
}
For further reference, please consider the following sections: