Api >

Service Portal REST API

Admin can create XCAPI Device with all possible data
Given I am authenticated as Admin
and there is a XCAPI Device Type
adding option support for SET_E164_DID_IN_TO
adding option support for CID_SCREENING
and there is a site with ID a062000000HbAsd

suppressLineNo possible values are: DEFAULT(use the trunk setting), ON, OFF

When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }, {
    "name": "concurrentLines",
    "value": 15
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "setE164DidInTo",
    "value": false
  }, {
    "name": "cidScreening",
    "value": "ALLOW_ANY"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/xcapi/device123
with following body:
{
  "href": "/api/customers/K0002/devices/xcapi/device123"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/xcapi/device123
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/devices/xcapi/device123",
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }, {
    "rel": "customer",
    "href": "/api/customers/K0002"
  }, {
    "rel": "activation",
    "href": "/api/customers/K0002/devices/xcapi/device123/activate"
  }, {
    "rel": "siteOptions",
    "href": "/api/customers/K0002/devices/xcapi/device123/site-options"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }, {
    "name": "concurrentLines",
    "value": 15
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "setE164DidInTo",
    "value": false
  }, {
    "name": "cidScreening",
    "value": "ALLOW_ANY"
  }]
}
Admin can create XCAPI Device with optional data
Given I am authenticated as admin
and there is a XCAPI Device Type
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/xcapi/device123
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/devices/xcapi/device123",
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/1"
  }, {
    "rel": "customer",
    "href": "/api/customers/K0002"
  }, {
    "rel": "activation",
    "href": "/api/customers/K0002/devices/xcapi/device123/activate"
  }, {
    "rel": "siteOptions",
    "href": "/api/customers/K0002/devices/xcapi/device123/site-options"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }, {
    "name": "concurrentLines",
    "value": 100
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "active",
    "value": true
  }, {
    "name": "useSiteOptionsFromSite",
    "value": true
  }]
}
Admin cannot use site from another Customer when creating device
Given I am authenticated as admin
and there is a XCAPI Device Type
and next Site ID will be 360
and there is a site with ID anotherSite for customer K0003
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/anotherSite"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "Site not allowed",
    "detailMessage": "Site [anotherSite] is not reachable for customer [K0002]",
    "path": "site",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create XCAPI Device with invalid concurrentLines value
Given I am authenticated as admin
and there is a XCAPI Device Type
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }, {
    "name": "concurrentLines",
    "value": 1410
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Invalid value for concurrentLines",
    "detailMessage": "concurrentLines value should be between 1 and 999",
    "path": "concurrentLines"
  }]
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/xcapi/device123
Then I should receive HTTP/1.1 404 Not Found
Cannot create Device if it will break Customer's Contract constraints
Given I am authenticated as admin
and there is another Customer with ID K0003
and there is a XCAPI Device Type
my Contract does not allow me to add more Devices
and next Site ID will be 360
and there is a site with ID anotherSite for customer K0003
When I send /api/customers/K0003/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/anotherSite"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
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 Unprovisioned Sip with duplicated ID
Given I am authenticated as Admin
and there is a XCAPI Device Type
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as admin
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Unique Identifier is not unique",
    "path": "uniqueIdentifier",
    "value": "device123"
  }]
}
Cannot create Unprovisioned Sip with empty ID
Given I am authenticated as Admin
and there is a XCAPI Device Type
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": ""
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'prePersist'. Please refer to embedded ConstraintViolations for details.",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create XCAPI device with wrong device type
Given I am authenticated as Admin
and there is a Unprovisioned Sip Device Type with name unprovisioned_sip
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/unprovisioned_sip"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "Cannot create XCAPI Device with type that is not XCAPI category",
    "path": "deviceType",
    "value": "/api/customers/K0002/device-types/unprovisioned_sip"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Admin Cannot create XCAPI device with not existing Device Type
Given I am authenticated as Admin
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/not_existing"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body
{
  "title": "Device Type not found",
  "detail": "Device Type with name not_existing not found",
  "described_by": "http://api.nfon.net/probs/device-type-not-found"
}
Admin cannot create XCAPI device with not existing Site
Given I am authenticated as Admin
and there is a XCAPI Device Type
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/not-existing"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body
{
  "detail": "Site [not-existing] not found for Customer [K0002]",
  "described_by": "http://api.nfon.net/probs/site-not-found"
}
Admin cannot create XCAPI device for missing Customer
Given I am authenticated as Admin
and there is a XCAPI Device Type
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0404/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body
{
  "title": "Customer not found",
  "detail": "Customer with identifier K0404 has not been found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
Non Admin user cannot create XCAPI device
Given I am authenticated as customer K0002
and there is a XCAPI Device Type
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/xcapi with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/XCAPI"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "device123"
  }, {
    "name": "concurrentLines",
    "value": 15
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }]
}
Then I should get HTTP/1.1 403 Forbidden
{
  "detail": "Access denied to [DeviceType] with id [XCAPI]",
  "title": "Access forbidden",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}