This API provides endpoints for managing pizza orders, including creating orders, adding items to orders, marking orders as done, and listing orders. Authentication is required for certain operations.
API tests can be found in file test-requests.http
Database schema can be found in file docker/postgres/docker-entrypoint-initdb.d/schema.sql
App queries can be found in file query.sql
make up
Stop all containers without losing data
make down
Delete all containers, volumes, and networks
make clear
Create a new order.
POST /orders
- Content-Type: application/json
{
"items": [
1,
1,
2
]
}
- 201 Created: Returns the created order.
{
"order_id": "dd9fd3a2c8405e8",
"items": [
4,
5,
6
],
"done": false
}
- 400 Bad Request: If the request body is invalid.
- 404 Not Found: Item not found.
Add items to an existing order.
POST /orders/{order_id}/items
- Content-Type: application/json
[
1,
1,
2
]
- 200 OK
- 400 Bad Request: If the request body is invalid.
- 404 Not Found: Order or Item not found.
- 409 Conflict: Order is already done.
Retrieve details of a specific order by its ID.
GET /orders/{order_id}
order_id
(path): The ID of the order to retrieve.
200 OK
: Returns the order details.
{
"order_id": "b7977e06244fc29",
"items": [
1,
2,
3
],
"done": false
}
404 Not Found
: If the order with the specified ID does not exist.
Changes field of existing order to 'done'.
POST /orders/{{order_id}}/done
- X-Auth-Key:
{{auth_key}}
- 200 OK
- 404 Not Found: Order not found.
- 409 Conflict: Order is already done.
- 401 Unauthorized: Auth key is not provided or does not match.
List all orders
GET /orders/[?done=1|0]
URL queries:
done
- If present, filters for done (?done=1) or not done (?done=0) orders. Omit to request all orders.
- X-Auth-Key:
{{auth_key}}
- 200 OK
[
{
"order_id": "544761bce741f18",
"done": false
},
{
"order_id": "dd9fd3a2c8405e8",
"done": true
}
]
- 400 Bad Request:
done
query is an invalid value. - 401 Unauthorized: Auth key is not provided or does not match.