Api >

Service Portal REST API

POST creates a Handset Device
Given I am authenticated as K0002
And there is a Base Device of Base family family-1 with MAC ABCDEF012345
And there is a Handset Device Type of Base family family-1 which supports BLUETOOTH_PIN option
When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
Then I should receive HTTP/1.1 201 Created with following body:
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345/handsets/Port0"
}
And Handset Port0 is connected with Base ABCDEF012345
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345/handsets/Port0 should return:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
POST fails meaningfully if Handset Device does not support bluetoothPin but one is provided
Given I am authenticated as K0002
And there is a Base Device of Base family family-1 with MAC ABCDEF012345
And there is a Handset Device Type of Base family family-1 which does not support BLUETOOTH_PIN option
When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "title": "Device option not supported",
  "detail": "Device option BLUETOOTH_PIN is not supported by device type Handset Device Type",
  "described_by": "http://api.nfon.net/probs/device-option-not-supported"
}
POST fails meaningfully if Handset Device does supports bluetoothPin but provided value is invalid
Given I am authenticated as K0002
And there is a Base Device of Base family family-1 with MAC ABCDEF012345
And there is a Handset Device Type of Base family family-1 which supports BLUETOOTH_PIN option
When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "12345"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "title": "bluetoothPin is invalid",
  "detail": "bluetoothPin should contain 4 digits, but 12345 was provided",
  "described_by": "http://api.nfon.net/probs/invalid-bluetooth-pin"
}
POST fails meaningfully if Handset Device cannot be created for given base
Given I am authenticated as K0002
And there is a Base Device of Base family family-1 with MAC ABCDEF012345
And there is no Handset Device Type of Base family family-1
When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "described_by": "http://api.nfon.net/probs/no-handset-type",
  "title": "No matching Handset Type for given Base",
  "detail": "There is no matching Handset type for Base Type [Base Device]"
}
POST fails meaningfully if Handset Device has invalid IPEI number when it is required
Given I am authenticated as K0002
And there is a Base Device of category Kirk and Base family family-1 with MAC ABCDEF012345 and Port Type IPEI
And there is a Handset Device Type of category Kirk and Base family family-1
and Port Type IPEI

When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "described_by": "http://api.nfon.net/probs/invalid-ipei-number",
  "title": "IPEI number is invalid",
  "detail": "IPEI number should contain 12 digits, but Port0 was provided"
}
POST fails meaningfully if Handset Device has invalid IPUI number when it is required
Given I am authenticated as K0002
And there is a Base Device of category Kirk and Base family family-1 with MAC ABCDEF012396 and Port Type IPUI
And there is a Handset Device Type of category Kirk and Base family family-1
and Port Type IPUI

When I send /api/customers/K0002/devices/base/ABCDEF012396/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "detail": "IPUI has to be a 10 characters long hex value but Port0 was provided",
  "title": "IPUI number is invalid",
  "described_by": "http://api.nfon.net/probs/invalid-ipui-number"
}
POST fails meaningfully if Base has already an IPEI Handset Device with given id
Given I am authenticated as K0002
And there is a Base Device of category Kirk and Base family family-1 with MAC ABCDEF012345 and Port Type IPEI
And there is a Handset Device Type of category Kirk and Base family family-1
and the Base has already a Handset with port 012345678912
and Port Type IPEI

When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "012345678912"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "described_by": "http://api.nfon.net/probs/device-id-not-unique",
  "title": "Device Id is not unique",
  "detail": "There is already a device with id ABCDEF012345-012345678912"
}
POST fails meaningfully if Base has already an IPUI Handset Device with given id
Given I am authenticated as K0002
And there is a Base Device of category Kirk and Base family family-1 with MAC ABCDEF012397 and Port Type IPUI
And there is a Handset Device Type of category Kirk and Base family family-1
and the Base has already a Handset with port 00ABC50871
and Port Type IPUI

When I send /api/customers/K0002/devices/base/ABCDEF012397/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "00ABC50871"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "detail": "There is already a device with id ABCDEF012397-00ABC50871",
  "title": "Device Id is not unique",
  "described_by": "http://api.nfon.net/probs/device-id-not-unique"
}
POST fails meaningfully if Handset Device port is not available to Base
Given I am authenticated as K0002
And there is a Base Device of Base family family-1 with MAC ABCDEF012345 which has Port123 unavailable
And there is a Handset Device Type of Base family family-1
When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port123"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "described_by": "http://api.nfon.net/probs/port-not-available",
  "title": "Port is not available",
  "detail": "Port ABCDEF012345-Port123 is not available for this base device"
}
Cannot create Handset Device if it will break Customer's Contract constraints
Given I am authenticated as customer K0003 And there is a Base Device of Base family family-1 with MAC ABCDEF012345
And there is a Handset Device Type of Base family family-1 which supports BLUETOOTH_PIN option
and my Contract does not allow me to add more Devices
When I send /api/customers/K0003/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }]
}
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"
  }]
}
Cannot create Handset for missing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "described_by": "http://api.nfon.net/probs/customer-not-found",
  "title": "Customer not found",
  "detail": "Customer with identifier K0404 has not been found"
}
Customer cannot create Handset Device for another Customer
Given I am authenticated as K0003
and there is a Base Device of Base family family-1 with MAC ABCDEF012345
And there is a Handset Device Type of Base family family-1 which supports BLUETOOTH_PIN option
When I send /api/customers/K0002/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot create Handset for Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Operator cannot create Handset for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/devices/base/ABCDEF012345/handsets as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "port",
    "value": "Port0"
  }, {
    "name": "bluetoothPin",
    "value": "8264"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}