Api >

Service Portal REST API

Admin can create ExternalLine Device with all possible data
Given I am authenticated as Admin
and there is a ExternalDevice 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/external-line with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/External%20Line"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "associatedMobilePhoneNumber",
    "value": "+1234567890333"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "setE164DidInTo",
    "value": false
  }, {
    "name": "cidScreening",
    "value": "ALLOW_ANY"
  }, {
    "name": "associatedMobilePhoneNumber",
    "value": "+1234567890333"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
with id #deviceId When I send /api/customers/K0002/devices?_q=External%20Line
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "offset": 0,
  "total": 1,
  "size": 1,
  "links": [],
  "items": [{
    "links": [],
    "data": [{
      "name": "deviceType",
      "value": "External Line"
    }, {
      "name": "active",
      "value": true
    }, {
      "name": "deviceMasterCategory",
      "value": "FMC"
    }, {
      "name": "associatedMobilePhoneNumber",
      "value": "+1234567890333"
    }]
  }]
}
Creation of External Line Device with duplicate associatedMobilePhoneNumber must fail
Given I am authenticated as Admin
and there is a ExternalDevice Device Type
adding option support for SET_E164_DID_IN_TO
adding option support for CID_SCREENING
andan existing there is a External Line device with ID device123 and an associatedMobilePhoneNumber +1232456789
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0002/devices/external-line with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/External%20Line"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "associatedMobilePhoneNumber",
    "value": "+1232456789"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "setE164DidInTo",
    "value": false
  }, {
    "name": "cidScreening",
    "value": "ALLOW_ANY"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
Admin cannot use site from another Customer when creating ExternalLine device
Given I am authenticated as admin
and there is a External Line 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/external-line with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/External%20Line"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/anotherSite"
  }],
  "data": [{
    "name": "associatedMobilePhoneNumber",
    "value": "+1234567890333"
  }]
}
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"
}
Admin cannot create External Line device with not existing Site
Given I am authenticated as Admin
and there is a External Line Device Type
When I send /api/customers/K0002/devices/external-line with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/External%20Line"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/not-existing"
  }],
  "data": [{
    "name": "associatedMobilePhoneNumber",
    "value": "+1234567890333"
  }]
}
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 External Line device for missing Customer
Given I am authenticated as Admin
and there is a External Line Device Type
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0404/devices/external-line with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/External%20Line"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "associatedMobilePhoneNumber",
    "value": "+1234567890333"
  }]
}
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"
}