-
Clone the repository:
git clone https://github.com/Hamedblue1381/vending-machine.git cd vending-machine
make build
make cli
Welcome to our Vending Machine API! This repository contains a simple RESTful API designed to manage vending machines and their inventory.
All API endpoints are accessible at http://localhost:8080/
.
Dispense an item by its unique identifier.
- Method: GET
- Path:
/item/{item}
- Parameters:
item
(required): The ID of the desired item.
-
Status code: 200 OK
-
Body:
-
Status code: 200 OK
-
Body:
{ "message": "Item dispensed successfully!" }
Retrieve a list of items currently available for purchase.
- Method: GET
- Path:
/insert
- Status code: 200 OK
- Body:
{ [ { "ID": 1, "Name": "Soda", "Count": 20 }, { "ID": 2, "Name": "Coffee", "Count": 19 } ] }
Obtain information about existing vending machines and their current stock levels.
- Method: GET
- Path:
/machines
- Status code: 200 OK
- Body:
{
[
{
"id": 0,
"stock": 40,
"coins": 0,
"items": [
{
"ID": 1,
"Name": "Soda",
"Count": 20
},
{
"ID": 2,
"Name": "Coffee",
"Count": 20
}
]
}
]
}
Add a new vending machine to the system.
- Method: POST
- Path:
/add-machine
- Body:
{
"count": 20
}