Files
rust-actixweb-diesel-api/readme.md
2020-12-02 01:11:42 +05:30

76 lines
1.5 KiB
Markdown

# Shopping API
Creates the Web API for a very basic e-commerce platform. The
server is backed by PostgreSQL database.
## APIs
### 1. GET /product
- Returns a JSON response with all the events, ordered by date of creation in ascending order.
- Output
```json
[
{
"productid": 5,
"productname": "Hammer",
"created_at": "2020-11-30T21:46:41.359298"
},
{
"productid": 4,
"productname": "Soap",
"created_at": "2020-11-30T21:46:41.359298"
}
]
```
### 2. POST /orders
- Accepts a JSON request for an order that comprises one or more tickets.
- Input
```json
{
"email": "mail@id.com",
"line_items": [
{
"productid": 4,
"quantity": 10
},
{
"productid": 5,
"quantity": 10
}
]
}
```
### 3. GET /orders (TODO)
- Returns a JSON response with all the orders, ordered by date of creation.
- Output
```json
{
“orders”: [
{
“id”: 1,
“email”: “test@example.com”,
“line_items”: [
{
“quantity”: 5,
“product”: {
“id”: 1,
“name”: “Product1”
}
},
],
}
]
}
```