- Description: Get user data
- Request params: userID or user_email
- Return: user object as defined below
- HTTP Response: 200 success, 404 user not found, 500 Server Error
{
"id": 0,
"name": "",
"role": "client",
"email": ""
}
- Description: add new client
- Body: user data as defined below
- Return: success or fail
- HTTP Response: 201 user created, 422 Unprocessable Request, 500 Server Error
{
"email": "",
"password": "",
"username": "",
"name": "",
"surname": ""
}
- Description: set virtual time
- Request params: a time string like (Wed Dec 08 2021 18:00:03 GMT+0100 (Ora standard dell’Europa centrale)) or an offset in seconds or a timestamp
- Return: offset from real time in seconds
- HTTP Response: 201 time updated
- Description: get set session time
- Return: an object as defined below
- HTTP Response: 200 success
{
"offset": 0,
"time": 1638982982,
}
- Description: save a new notification for user_id
- Request params: user_id
- Body: an object as defined below
- Return: success or fail
- HTTP Response: 201 notification updated, 400 Bad Request, 500 Server Error
{
"message": "",
"object": "",
}
- Description: set a notification as seen
- Request params: notification_id
- Return: success or fail
- HTTP Response: 201 notification updated, 400 Bad Request, 500 Server Error
- Description: get all notification for user_id
- Request params: user_id
- Return: an object as defined below
- HTTP Response: 200 success, 404 user not found, 500 Server Error
{
"id": 0,
"message": "",
"object": "",
"seen": 0
}
- Description: get all orders based on the filter
- Request params: Filter (orderID (will return only an object) or user_email or order status (like: pending)), if all is passed will return all orders otherwise only of the current week
- Return: an array of objects or a single one as defined below
- HTTP Response: 200 success, 404 order not found, 422 Unprocessable Request, 500 Server Error
{
"id": 0,
"user_id": 0,
"status": "",
"price": 0,
"pickup_time": "",
"pickup_place": "",
"timestamp": 0,
"user": {
"username": "",
"email": "",
"role": "client",
"name": "",
"surname": "",
},
"products": [{
"product_id": 0,
"quantity": 0
}, ],
}
- Description: insert a new order for user_id
- Request params: user_id
- Body: an object as defined below
- Return: success or fail
- HTTP Response: 201 success, 400 Bad Request, 412 Precondition Failed, 422 Unprocessable Request, 500 Server Error
{
"order": {
"status": "",
"pickup_time": "",
"pickup_place": "",
},
"products": [{
"product_id": 0,
"quantity": 0
}, ],
}
- Description: update an order
- Request params: order_id
- Body: an object as defined below
- Return: success or fail
- HTTP Response: 201 success, 400 Bad Request, 412 Precondition Failed, 422 Unprocessable Request, 500 Server Error
{
"order": {
"status": "",
"pickup_time": "",
"pickup_place": "",
},
"products": [{
"product_id": 0,
"quantity": 0
}, ],
}
Get the list of all the products of a farmer
http://localhost:3001/api/products/farmer/4
update the products amount, of a farmer
POST /api/farmer/products/update HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 52
{
"farmer_id": 4,
"product_id": 2,
"quantity":200,
"price":20,
}
POST /api/wallet/update HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 52
{
"client_email": "john.doe@demo01.it",
"amount": 10
}
Update the value of the wallet of a specific amount
The user need to be authenticated. Return a list of the products in the database
http://localhost:3001/api/products
{
"id": 1,
"quantity": 10,
"price": 5,
"name": "product name",
"Farmer": "farmerName farmerSurname"
}
Insert a new client in the databse
The user need to be authenticated. Return the amount of money that are present in the wallet client whose mail is passed as parameter:
http://localhost:3001/api/orders/john.doe@demo01.it
{
"wallet": 50
}
POST /api/basketProduct
Host: localhost
Content-Type: application/json
{
"product_id": 1,
"quantity": 4
}
Delete the element associated with the id in the received object from the basket of the client that called the API. Then, if quantity is not 0, insert the received object in the database
The user need to be authenticated.
http://localhost:3001/api/basketProduct
Delete all the element in basket associated with the user that called the API
The user need to be authenticated. Return the list of the products in basket associated with the user that called the API
http://localhost:3001/api/basketProduct
{
"id": 1,
"quantity": 10,
"price": 5,
"name": "product name",
"Farmer": "farmerName farmerSurname"
}