Api >

Service Portal REST API

POST attaches Device to Extension
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345 and there is a PhoneExtension with extensionNumber 201 When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
And location header is equal to http://localhost:9998/api/customers/K0002/targets/phone-extensions/201/devices
Given I am authenticated as K0002
When I send /api/customers/K0002/targets/phone-extensions/201/devices
Then I should receive HTTP/1.1 200 OK with following body:
{
  "items": [{
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345",
    "links": [{
      "rel": "deletion",
      "href": "/api/customers/K0002/targets/phone-extensions/201/devices/ABCDEF012345"
    }],
    "data": [{
      "name": "uniqueIdentifier",
      "value": "ABCDEF012345"
    }, {
      "name": "masterCategory",
      "value": "STANDARD"
    }, {
      "name": "deviceType",
      "value": "standard"
    }, {
      "name": "category",
      "value": "category"
    }]
  }]
}
POST sets first Device attached to Extension as a Primary Device
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345 and there is a PhoneExtension with extensionNumber 201 When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
When I send /api/customers/K0002/targets/phone-extensions/201
Then I should receive HTTP/1.1 200 OK with following body:
{
  "href": "/api/customers/K0002/targets/phone-extensions/201",
  "links": [{
    "rel": "primaryDevice",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
POST returns 400 if trying to attach Base Device to Extension
Given I am authenticated as K0002
and there is a base device with Id ABCDEF012345 and there is a PhoneExtension with extensionNumber 201 When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/base/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Cannot attach Base device.",
    "value": "ABCDEF012345",
    "path": "deviceToAttach"
  }]
}
POST allows to attach Extended Base Device to Extension
Given I am authenticated as K0002
and there is a base device with Id ABCDEF012345 and there is a PhoneExtension with extensionNumber 201 When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/base/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
POST returns 400 if trying to attach Device that is already attached to some Extension
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345
and there is a PhoneExtension with extensionNumber 201
and there is another PhoneExtension with extensionNumber 202
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
Then if I again try to assign this device to another phone extension /api/customers/K0002/targets/phone-extensions/202/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
{
  "errors": [{
    "message": "Device ABCDEF012345 is already attached to Phone Extension 201",
    "value": "ABCDEF012345",
    "path": "deviceToAttach"
  }]
}
POST returns 400 if trying to attach Device twice to same Extension
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345
and there is a PhoneExtension with extensionNumber 201
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
Then if I again try to assign this device to the same phone extension /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
{
  "errors": [{
    "message": "Device ABCDEF012345 is already attached to Phone Extension 201",
    "value": "ABCDEF012345",
    "path": "deviceToAttach"
  }]
}
POST attaches XCAPI Device even if it is already attached to some Extension
Given I am authenticated as K0002
and there is a XCAPI device with Id ABCDEF012345
and there is a PhoneExtension with extensionNumber 201
and there is another PhoneExtension with extensionNumber 202
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/xcapi/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
When I send /api/customers/K0002/targets/phone-extensions/201/devices
Then I should receive HTTP/1.1 200 OK with following body:
{
  "items": [{
    "href": "/api/customers/K0002/devices/xcapi/ABCDEF012345"
  }]
}
Given I am authenticated as K0002
Then if I again try to assign this device to another phone extension /api/customers/K0002/targets/phone-extensions/202/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/xcapi/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
When I send /api/customers/K0002/targets/phone-extensions/202/devices
Then I should receive HTTP/1.1 200 OK with following body:
{
  "items": [{
    "href": "/api/customers/K0002/devices/xcapi/ABCDEF012345"
  }]
}
Cannot attach XCAPI Device as secondary device
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345 and there is a PhoneExtension with extensionNumber 201
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
and there is a XCAPI device with Id ABCDEF678901
Then if I try to assign XCAPI device as secondary device /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/xcapi/ABCDEF678901"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
and response body
{
  "errors": [{
    "message": "Phone extension with Xcapi attached cannot have any other devices attached! If you wish to attach Xcapi device, deattach all other devices first."
  }]
}
Cannot attach Device as secondary device if there is already XCAPI device attached
Given I am authenticated as K0002
and there is a PhoneExtension with extensionNumber 201
and there is a XCAPI device with Id ABCDEF678901
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/xcapi/ABCDEF678901"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345 Then if I try to assign standard device as secondary device /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
and response body
{
  "errors": [{
    "message": "Phone extension with Xcapi attached cannot have any other devices attached! If you wish to attach this device, deattach the Xcapi device first."
  }]
}
Cannot attach DAKS Device as secondary device
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345 and there is a PhoneExtension with extensionNumber 201
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
and there is a DAKS device with Id ABCDEF678901
Then if I again try to assign DAKS device as secondary device /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/unprovisioned-sip/ABCDEF678901"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
and response body
{
  "errors": [{
    "message": "Phone extension with DAKS attached cannot have any other devices attached! If you wish to attach DAKS device, deattach all other devices first."
  }]
}
Cannot attach Device as secondary device if there is already DAKS device attached
Given I am authenticated as K0002
and there is a PhoneExtension with extensionNumber 201
and there is a DAKS device with Id ABCDEF678901
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/unprovisioned-sip/ABCDEF678901"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as K0002
and there is a standard device with Id ABCDEF012345 Then if I try to assign standard device as secondary device /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
and response body
{
  "errors": [{
    "message": "Phone extension with DAKS attached cannot have any other devices attached! If you wish to attach this device, deattach the DAKS device first."
  }]
}
Customer cannot attach device of another Customer
Given there is a Phone Extension with extension number 201 for Customer K0002
and Customer K0003 has a standard device with ID ABCDEF012345
and I am authenticated as customer K0002
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0003/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 403 Forbidden
And Content-Type header should be application/api-problem+json
And response should look like:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Admin cannot attach one Customer's device to another Customer's Phone Extension
Given there is a Phone Extension with extension number 201 for Customer K0002
and Customer K0003 has a standard device with ID ABCDEF012345
and I am authenticated as admin
When I send /api/customers/K0002/targets/phone-extensions/201/devices
As application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0003/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
And response should look like:
{
  "errors": [{
    "message": "Device is invalid for selected Phone Extension",
    "detailMessage": "Provided device ABCDEF012345 is invalid for Phone Extension 201",
    "path": "deviceToAttach"
  }]
}
Admin cannot attach device of missing Customer
Given I am authenticated as admin
and there is no customer K0404
When I send /api/customers/K0404/targets/phone-extensions/1/devices As application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 404 Not Found
And Content-Type header should be application/api-problem+json
And response should look like:
{
  "described_by": "http://api.nfon.net/probs/customer-not-found",
  "title": "Customer not found",
  "detail": "Customer with identifier K0404 has not been found"
}
Cannot attach device to missing Phone Extension
Given I am authenticated as K0002
And there is a standard device with unique identifier ABCDEF012345
When I send /api/customers/K0002/targets/phone-extensions/404/devices As application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF012345"
  }]
}
Then response code should be equal HTTP/1.1 404 Not Found
And Content-Type header should be application/api-problem+json
And response should look like:
{
  "title": "Extension not found",
  "detail": "Extension with extension number 404 has not been found",
  "described_by": "http://api.nfon.net/probs/extension-not-found"
}
Cannot attach missing device
Given I am authenticated as K0002
and there is a Phone Extension with extension number 201
and there is no standard device with Id ABCDEF000404 When I send /api/customers/K0002/targets/phone-extensions/201/devices As application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0002/devices/standard/ABCDEF000404"
  }]
}
Then response code should be equal HTTP/1.1 404 Not Found
And Content-Type header should be application/api-problem+json
And response should look like:
{
  "title": "Device not found",
  "detail": "Device with unique identifier ABCDEF000404 has not been found",
  "described_by": "http://api.nfon.net/probs/device-not-found"
}
System Integrator cannot attach Phone Extension Device of Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/targets/phone-extensions/201/devices As application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0003/devices/standard/ABCDEF000404"
  }]
}
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 attach Phone Extension Device of Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/phone-extensions/201/devices As application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceToAttach",
    "href": "/api/customers/K0003/devices/standard/ABCDEF000404"
  }]
}
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"
}