Api >

Service Portal REST API

POST Creates device of type Operator Panel (minimum required fields)
Given I am authenticated as Admin
And there is Operator Panel Device Type nreception
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/operator-panel/01-23-45-67-89-ab
And Operator Panel with macAddress 01-23-45-67-89-ab exists
POST Creates device with default values
Given I am authenticated as Admin
And there is Operator Panel Device Type nreception with Preferred Firmware 1.0
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }]
}
Then /api/customers/K0002/devices/operator-panel/01-23-45-67-89-ab should be populated with default values:
{
  "links": [{
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/nreception/firmwares/1.0"
  }],
  "data": []
}
POST Creates device of type Operator Panel (all fields)
Given I am authenticated as Admin
And there is Operator Panel Device Type nreception with Firmware Release Version 150.123
And there is Site Berlin (salesforceId: 54526563554535)
And there is Device with Mac Address 00-11-22-33-44
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/nreception/firmwares/150.123"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/54526563554535"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }, {
    "name": "license",
    "value": "licenseKey"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
Then /api/customers/K0002/devices/operator-panel/01-23-45-67-89-ab should return
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/nreception/firmwares/150.123"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/54526563554535"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }, {
    "name": "license",
    "value": "licenseKey"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
POST Mac address should be unique
Given I am authenticated as Admin
And there is Opeperator Panel Device Type nreception
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }]
}
When I try send same Mac address /api/customers/K0002/devices/operator-panel using using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "errors": [{
    "message": "Mac Address '01-23-45-67-89-ab' is not unique",
    "path": "macAddress"
  }]
}
POST When License is present should not be longer than 100 characters
Given I am authenticated as Admin
And there is Opeperator Panel Device Type nreception
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }, {
    "name": "license",
    "value": "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1"
  }]
}
HTTP/1.1 400 Bad Request
{
  "errors": [{
    "message": "Length of provided license was 101, but allowed maximum is 100",
    "path": "license"
  }]
}
POST is allowed for Admin
Given I am admin
And there is Operator Panel Device Type nreception
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }]
}
Then I should receive HTTP/1.1 201 Created
POST is not allowed for non Admin users
Given I am Customer K0002
And there is Operator Panel Device Type nreception
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
Cannot create Device if it will break Customer's Contract constraints
Given I am authenticated as Admin
and there is Operator Panel Device Type nreception
and Contract does not allow to add more Devices for Customer K0002
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/operator-panel using application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/nreception"
  }],
  "data": [{
    "name": "macAddress",
    "value": "01-23-45-67-89-ab"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Customer contract type does not allow to add more Devices"
  }]
}