Api >

Service Portal REST API

POST creates Softphone Device with required and default attributes
Given I am authenticated as Admin
and there is a Softphone Device Type with name softphone
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "softphoneTest0123"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/softphone/softphoneTest0123
with following body:
{
  "href": "/api/customers/K0002/devices/softphone/softphoneTest0123"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/softphone/softphoneTest0123
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/devices/softphone/softphoneTest0123",
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/1"
  }, {
    "rel": "customer",
    "href": "/api/customers/K0002"
  }, {
    "rel": "activation",
    "href": "/api/customers/K0002/devices/softphone/softphoneTest0123/activate"
  }, {
    "rel": "siteOptions",
    "href": "/api/customers/K0002/devices/softphone/softphoneTest0123/site-options"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "softphoneTest0123"
  }, {
    "name": "active",
    "value": true
  }, {
    "name": "useSiteOptionsFromSite",
    "value": true
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }]
}
POST creates Softphone Device with required and optional attributes
Given I am authenticated as Admin
and there is a Softphone Device Type with name softphone
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "softphoneTest0123"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/softphone/softphoneTest0123
with following body:
{
  "href": "/api/customers/K0002/devices/softphone/softphoneTest0123"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/softphone/softphoneTest0123
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/devices/softphone/softphoneTest0123",
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/1"
  }, {
    "rel": "customer",
    "href": "/api/customers/K0002"
  }, {
    "rel": "activation",
    "href": "/api/customers/K0002/devices/softphone/softphoneTest0123/activate"
  }, {
    "rel": "siteOptions",
    "href": "/api/customers/K0002/devices/softphone/softphoneTest0123/site-options"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "softphoneTest0123"
  }, {
    "name": "active",
    "value": true
  }, {
    "name": "useSiteOptionsFromSite",
    "value": true
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
Cannot create Device if it will break Customer's Contract constraints
Given I am authenticated as Admin
and there is another customer K0003
and there is a Softphone Device Type with name softphone
my Contract does not allow me to add more Devices
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0003/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/softphone"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789softphone"
  }]
}
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 Softphone Device with duplicated ID
Given I am authenticated as Admin
and there is a Softphone Device Type with name softphone
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as Admin
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "device id not unique",
    "path": "uniqueIdentifier"
  }]
}
Cannot create Softphone Device with empty ID
Given I am authenticated as Admin
and there is a Softphone Device Type with name softphone
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": ""
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "device id not defined",
    "path": "uniqueIdentifier"
  }]
}
Cannot create Device with not existing Device Type
Given I am authenticated as Admin
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/not-existing"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
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"
}
Cannot create Device with invalid Device Type
Given I am authenticated as Admin
and there is a Base Device Type with name base
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/base"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Cannot create Softphone Device with type that is not Softphone category",
    "path": "deviceType",
    "value": "/api/customers/K0002/device-types/base"
  }]
}
Cannot create Device with not existing Site
Given I am authenticated as Admin
and there is a Softphone Device Type with name softphone
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/not-existing"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
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"
}
Cannot create Device with Site that belongs to another Customer
Given I am authenticated as admin
and there is a Device Type device type with name softphone
and there is a site with ID anotherSite for customer K0003
When I send /api/customers/K0002/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/anotherSite"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Site not allowed",
    "detailMessage": "Site [anotherSite] is not reachable for customer [K0002]",
    "path": "site"
  }]
}
Admin Cannot create Device with missing Customer
Given I am authenticated as Admin
and there is a Device Type device type with name softphone
When I send /api/customers/K0404/devices/softphone with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/softphone"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
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"
}