- Getting a list of entities:
GET /api/<entity>?<Filter parameters><paging paremeters>
- Getting one entity by id:
GET /api/<entity>/{id}
- Creating a new entity:
POST /api/<entity> (Body: JSON)
customer:
| Field Name | Type | Description | Example |
|---|---|---|---|
| firstName | string | Петр | |
| middleName | string | Петрович | |
| lastName | string | Петров | |
| birthdate | string, date format: dd.MM.YYYY | birth date | 25.04.2019 |
| id | Integer number | unique id generated upon creation | 9000 |
device:
| Field Name | Type | Description | Example |
|---|---|---|---|
| deviceType | string | device type (from a predefined set) | Smartphone |
| modelName | string | Galaxy S10+ | |
| manufactureDate | string, date format: dd.MM.YYYY | date of issue | 25.04.2019 |
| manufacturer | string | Samsung | |
| colorName | string | черный | |
| colorRGB | Integer number | integer representation (rgb) | 0 |
| price | Integer number | integer price | 12499000 |
| id | Integer number | unique id generated upon creation | 1126970 |
bill:
| Field Name | Type | Description | Example |
|---|---|---|---|
| customerId | Integer number | 9001 | |
| totalPrice | Integer number | integer price represented in penny | 31415926 |
| purchaseDateTime | String, date/time format:dd.MM.YYYY HH:mm:ss | purchase time and date | 01.01.2019 07:50:22 |
| items | List of BillItem |
BillItem: (as part of bill)
| Field Name | Type | Description | Example |
|---|---|---|---|
| deviceId | Integer number | 1004709 | |
| quantity | Integer number | number of devices | 100 |
| price | Integer number | price at the moment of purchase | 490 |
- you should not specify
idin POST request, otherwise it will be considered as an invalid field - if you specify
colorNameandcolorRGBfor device in POST request than new color with this name and colorRGB will be added to color storage - if you specify only
colorNamethan this api tries to find this color name in color storage. In case of success, json will return with a corresponding colorRGB code, otherwise it will not accept thePOSTquery - only parameter
colorRGBis not required - api doesn't accept empty or null fields
GET /api/<entity> options
-
orderBy:String- fields to order by separated by comma, e.g.manufactureDate,-totalPrice -
pageItems:long- number of elements on a single page -
page:long- page number -
offset:long- offset param -
the default is paginated output from 1 page with 10 entities per page, but if you specified the
offsetparameter and don't specify thepageparameter than the offset output will be used -
anything else is considered a filter option
-
some fields support range:
birthdate,price,manufactureDate,totalPrice,purchaseDateTime, e.g.priceFrom,priceToe.t.c. -
some fields support search by prefix:
firstName,middleName,lastName,modelName,deviceType,manufacturer, e.g.firstNamePrefix,modelNamePrefix,manufacturerPrefixe.t.c. -
-can be used before value of orderBy to reverse the result, e.g.orderBy=-totalPrice -
for the
billentity filtering queries by nested items are also available:
GET /api/bill?deviceId=11&quantity=30&price=499
POST /api/device
body:
{
"price": "499",
"deviceType": "Smartphone",
"manufactureDate": "09.01.2007",
"colorName": "black",
"colorRGB" : "0",
"manufacturer": "Foxconn",
"modelName": "iPhone"
}
GET /api/device?priceFrom=100&priceTo=500&orderBy=manufacturer
- you can add new device type to device type storage and see the available storage types by
GETquery
GET /api/device/type (no arguments)
POST /api/device/type (Body: String)
| Device type |
|---|
| smartphone |
| laptop |
| smart watches |
| tablet |
- you can add new color to color storage and see the available storage colors by
GETquery
GET /api/device/color (no arguments)
POST /api/device/color (Body: JSON)
color:
| Field Name | Type | Description | Example |
|---|---|---|---|
| colorName | String | color name | black |
| colorRGB | Integer number | integer representation (rgb) | 0 |
| Color name | rgb(r, g, b) |
|---|---|
| черный | rgb(0, 0, 0) |
| серый | rgb(128, 128, 128) |
| красный | rgb(255, 0, 0) |
| Золотистый | rgb(255, 215, 0) |
| Синий | rgb(0, 0, 255) |
| Серебристый | rgb(192, 192, 192) |
| Белый | rgb(255, 255, 255) |
| Коричневый | rgb(150, 75, 0) |
| Оранжевый | rgb(255, 165, 0) |
| Бежевый | rgb(245, 245, 220) |
| Желтый | rgb(255, 255, 0) |
| Зеленый | rgb(0, 128, 0) |
| Голубой | rgb(66, 170, 255) |
| Фиолетовый | rgb(139, 0, 255) |
| Розовый | rgb(252, 15, 192) |
In case of error this JSON will be returned:
| Field Name | Type | Description | Example |
|---|---|---|---|
| error.type | String | error type | invalid query parameter format |
| error.message | String | error description | the value '20-04-1980s' of 'birthdate' parameter does not match the date format: dd.MM.yyyy |
For convenience and clarity, you can also use UI, which is a simple html page with input fields. It supports all available GET and POST queries.