-
Notifications
You must be signed in to change notification settings - Fork 2
server_api
Here you will find the documentation of the server microservice of the EatUp project
All the information about the products available.
GET /api/v1/products
Fetch the products
Name | Example | Description |
---|---|---|
category |
?...&category=XXXXXX... |
The category to include in the response. It can be used multiple times to fetch all the selected categories |
allergy |
?...&allergy=XXXXXX... |
Excludes all the products that contains any of the specified allergies. It can be used multiple times. |
Examples
fetch("/api/v1/api/v1/products", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
[
{
id: "XXXXXX",
name: "YYYYYY",
description: "ZZZZZZ",
img_id: "YYYYYYY.png",
price: 42.0,
allergies: [
{
id: "AAAAAAA",
name: "BBBBBBB",
img_id: "CCCCCCC.png"
}
...
],
categories: [
{
id: "DDDDDDD",
name: "EEEEEEE"
}
...
]
},
...
]
fetch("/api/v1/api/v1/products?category=EEEEEEE&allergy=BBBBBB", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
If XXXXXX is the category for starters and YYYYYY the allergy lactose; this are the products:
200
[
{
id: "XXXXXX",
name: "YYYYYY",
description: "ZZZZZZ",
img_id: "YYYYYYY.png",
price: 42.0,
allergies: [
{
id: "AAAAAAA",
name: "BBBBBBB",
img_id: "CCCCCCC.png"
}
...
],
categories: [
{
id: "DDDDDDD",
name: "EEEEEEE"
}
...
]
},
...
]
The moment when the client is actively using the app in a table
GET /api/v1/sessions
Fetch all the sessions
Name | Example | Description |
---|---|---|
in_progress |
?...&in_progress=true/false... |
Filter only the active or inactive sessions |
table_id |
?...&table_id=XXXXXX... |
Filter the sessions done in a specific table |
Examples
fetch("/api/v1/api/v1/sessions", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
[
{
id: "XXXXXX",
table_id: "YYYYYY",
in_progress: true/false
},
...
]
fetch("/api/v1/api/v1/sessions?in_progress=true", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
[
{
id: "XXXXXX",
table_id: "YYYYYY",
in_progress: true/false
},
...
]
fetch("/api/v1/api/v1/sessions?table_id=YYYYYY", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
[
{
id: "XXXXXX",
table_id: "YYYYYY",
in_progress: true/false
},
...
]
GET /api/v1/session_id/:simple_id
Fetch the session_id with the simple_id
Name | Example | Description |
---|---|---|
simple_id |
.../XXXXXX YYYYYY ZZZZZZ/... |
The simple_id of the session |
Examples
fetch("/api/v1/api/v1/session_id/XXXXXX YYYYYY ZZZZZZ", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
{
"simple_id": "XXXXXX YYYYYY ZZZZZZ",
"id": "AAAAAAA",
"qr_img": "/qr/AAAAAAA.png"
}
fetch("/api/v1/api/v1/session_id/XXXXXX YYYYYY ZZZZZZ", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
409
No session with id XXXXXX YYYYYY ZZZZZZ
POST /api/v1/session/:table_id
Create a new session
Name | Example | Description |
---|---|---|
table_id |
.../XXXXXX/... |
The id of the table where the session should be created |
Examples
fetch("/api/v1/api/v1/session/BBBBBBB", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
{
"simple_id": "XXXXXX YYYYYY ZZZZZZ",
"id": "AAAAAAA",
"qr_img": "/qr/AAAAAAA.png"
}
fetch("/api/v1/api/v1/session/BBBBBBB", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
409
There is already a session in progress for table mesa
PATCH /api/v1/session/:session_id/end
Make sure to end this session.
Name | Example | Description |
---|---|---|
session_id |
.../XXXXXX/... |
The id of the session to end |
Examples
fetch("/api/v1/api/v1/session/AAAAAAA/end", {
method: "PATCH",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
"Session ended"
fetch("/api/v1/api/v1/session/AAAAAAA/end", {
method: "PATCH",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
409
Invalid session id
Logic to manage the orders made by the clients in a session.
GET /api/v1/orders/:session_id
Fetch all the orders of a session
Name | Example | Description |
---|---|---|
session_id |
.../XXXXXX/... |
The id of the session |
Examples
fetch("/api/v1/api/v1/orders/AAAAAAA", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
[
{
"id": "AAAAAAA",
"products": [
{
"id": "BBBBBBB",
"quantity": 2,
"product": {
"id": "CCCCCCC",
"name": "Bruschetta",
"description": "Tomato, garlic, basil, olive oil",
"img_id": "bruchetta.png",
"price": 5.0,
"allergies": [
{
"id": "DDDDDDD",
"name": "Gluten",
"img_id": "gluten.png"
},
{
"id": "EEEEEEE",
"name": "Lactose",
"img_id": "lactose.png"
}
],
"categories": [
{
"id": "FFFFFFF",
"name": "Appetizers"
}
]
}
},
...
],
},
...
]
fetch("/api/v1/api/v1/orders/AAAAAAA", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
409
Invalid session id
POST /api/v1/orders/:session_id
Create a new order in a session
Name | Example | Description |
---|---|---|
session_id |
.../XXXXXX/... |
The id of the session |
Examples
fetch("/api/v1/api/v1/orders/AAAAAAA", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(
{
"products": [
{
"quantity": 3
"product": {
"id": "BBBBBBB"
"name": "Bruschetta"
"description": "Tomato, garlic, basil, olive oil"
"img_id": "bruchetta.png"
"price": 5.0
"allergies": [
{
"id": "DDDDDDD"
"name": "Gluten"
"img_id": "gluten.png"
},
{
"id": "EEEEEEE"
"name": "Lactose"
"img_id": "lactose.png"
}
],
"categories": [
{
"id": "FFFFFFF"
"name": "Appetizers"
}
]
}
},
...
]
}
)
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
"Order created"
fetch("/api/v1/api/v1/orders/BBBBBBB", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(
{
"products": [
{
"quantity": 3
"product": {
"id": "BBBBBBB"
"name": "Bruschetta"
"description": "Tomato, garlic, basil, olive oil"
"img_id": "bruchetta.png"
"price": 5.0
"allergies": [
{
"id": "DDDDDDD"
"name": "Gluten"
"img_id": "gluten.png"
},
{
"id": "EEEEEEE"
"name": "Lactose"
"img_id": "lactose.png"
}
],
"categories": [
{
"id": "FFFFFFF"
"name": "Appetizers"
}
]
}
},
...
]
}
)
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
409
Invalid session id
This section contains the documentation for the special requests
GET /
Ping request to check if the server is up
GET /:file_route
Allows to fetch all files in the public directory of the installation volume.
Name | Example | Description |
---|---|---|
file_route |
.../qr/AAAAAAA.png/... |
The route of the file |
Examples
fetch("/qr/AAAAAAA.png", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
200
**PNG file**
fetch("/qr/BBBBBBB.png", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));
Response:
This is the result
404
"QR not found. Are you sure the QR should be valid?"
OPTIONS /*
CORS preflight request.
This are the meanings of the symbols used in this document
Element | Meaning |
---|---|
:session_id |
The id of the session |
:table_id |
The id of the table |
true/false |
A boolean value. It must be true or false
|
XXXXXX |
Some value that would be replaced for something else in the real situation. |
... |
More parameters can be added to the request |
Code | Meaning | Description |
---|---|---|
200 |
200 OK | The request was successful. |
404 |
404 Not Found | The resource does not exist. |
409 |
409 Conflict | Something is not right with the request. |
500 |
500 Internal Server Error | Something went wrong on the server. Please contact with the administrator. |
501 |
501 Not Implemented | The endpoint is not implemented yet. |
Made with ❤️ using api_docs_generator v0.7.0.