Skip to content
Snippets Groups Projects
README.md 1.54 KiB
Newer Older
# Order Service
Komínek, Martin's avatar
Komínek, Martin committed

Order service for SWA project.
Komínek, Martin's avatar
Komínek, Martin committed

## Usage
Komínek, Martin's avatar
Komínek, Martin committed

Run service from published image:
Komínek, Martin's avatar
Komínek, Martin committed

```
Komínek, Martin's avatar
Komínek, Martin committed
docker compose up
Komínek, Martin's avatar
Komínek, Martin committed
```

To see Swagger UI you can visit:
```
http://localhost:PORT/swagger-ui/index.html
```
Komínek, Martin's avatar
Komínek, Martin committed

## Logging
Komínek, Martin's avatar
Komínek, Martin committed

Logs are printed to the standard output.
Komínek, Martin's avatar
Komínek, Martin committed

## API description
Komínek, Martin's avatar
Komínek, Martin committed

### Get all items
Komínek, Martin's avatar
Komínek, Martin committed

```HTTP
GET /api/orders
```
Komínek, Martin's avatar
Komínek, Martin committed

### Add new item

- If new item does not contain following neccesarry keys: `["idCustomer", "userName","orderItems"]` the return code will be **400**. 
- In case everything is OK the return code will be **200**.

```HTTP
POST /api/orders HTTP/1.1
Content-Type: application/json
{
  "idOrder": 0,
  "idCustomer": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "userName": "string",
  "orderItems": [
    {
      "id": 0,
      "productName": "string",
      "quantity": 0
    }
  ]
}
```
Komínek, Martin's avatar
Komínek, Martin committed

### Delete item
- If some server error occurs return code will be  **404**. 
- If item with ID does not exist the return code will be **204**. 
- In case everything is OK the return code will be **200**.
Komínek, Martin's avatar
Komínek, Martin committed

```HTTP
DELETE /api/orders/{{id}} HTTP/1.1
Content-Type: application/json
```
Komínek, Martin's avatar
Komínek, Martin committed

### Update item
- If some server error occurs return code will be  **404**.
- If item with ID does not exist the return code will be **204**.
- In case everything is OK the return code will be **200**.

```HTTP
PUT /api/orders/{{id}} HTTP/1.1
Content-Type: application/json
{
  "idOrder": 0,
  "idCustomer": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "userName": "string",
  "orderItems": [
    {
      "id": 0,
      "productName": "string",
      "quantity": 0
    }
  ]
}
Komínek, Martin's avatar
Komínek, Martin committed
```