Api >

Service Portal REST API

Can create Lync Option
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as Admin
and next available identifier for Lync Site is 134
When I send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as Admin
When I send /api/customers/K0002/targets/phone-extensions/201/lync/134
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/targets/phone-extensions/201/lync/134",
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }, {
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/LYNC"
  }],
  "data": [{
    "name": "extensionNumber",
    "value": "201"
  }, {
    "name": "inboundNumber",
    "value": "+48 (22) 1111-119"
  }, {
    "name": "lync",
    "value": "Lync Site"
  }]
}
And there is attached Lync Softphone Device
Can create Lync Option
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as operator
and next available identifier for Lync Site is 134
When I send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as operator
When I send /api/customers/K0002/targets/phone-extensions/201/lync/134
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/targets/phone-extensions/201/lync/134",
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }, {
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/LYNC"
  }],
  "data": [{
    "name": "extensionNumber",
    "value": "201"
  }, {
    "name": "inboundNumber",
    "value": "+48 (22) 1111-119"
  }, {
    "name": "lync",
    "value": "Lync Site"
  }]
}
And there is attached Lync Softphone Device
Can create Lync Option
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as system-integrator
and next available identifier for Lync Site is 134
When I send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as system-integrator
When I send /api/customers/K0002/targets/phone-extensions/201/lync/134
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/targets/phone-extensions/201/lync/134",
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }],
  "data": [{
    "name": "extensionNumber",
    "value": "201"
  }, {
    "name": "inboundNumber",
    "value": "+48 (22) 1111-119"
  }, {
    "name": "lync",
    "value": "Lync Site"
  }]
}
And there is attached Lync Softphone Device
Can create Lync Option
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as K0002
and next available identifier for Lync Site is 134
When I send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as K0002
When I send /api/customers/K0002/targets/phone-extensions/201/lync/134
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/targets/phone-extensions/201/lync/134",
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }, {
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/LYNC"
  }],
  "data": [{
    "name": "extensionNumber",
    "value": "201"
  }, {
    "name": "inboundNumber",
    "value": "+48 (22) 1111-119"
  }, {
    "name": "lync",
    "value": "Lync Site"
  }]
}
And there is attached Lync Softphone Device
Should not allow to create more than one Lync Option for Phone Extension
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as Admin
When I send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as Admin
When I again send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }, {
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/LYNC"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "PhoneExtension 201 has already Lync Option assigned"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Should not allow to create Lync Option when required links are missing
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as Admin
When I again send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": []
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Value must be provided",
    "path": "lyncSite"
  }, {
    "message": "Value must be provided",
    "path": "inboundTrunkNumber"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Should not create Lync Option when provided Inbound Trunk Number does not belong to requested Phone Extension
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as Admin
and there is an another PhoneExtension with extensionNumber 301 and display name AnotherPhoneExtension
When I send /api/customers/K0002/targets/phone-extensions/301/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Inbound Trunk Number does not belong to PhoneExtension 301",
    "path": "inboundTrunkNumber",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Should not create Lync Option if limit of devices for Customer is reached
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as Admin
and there is a device with unique identifier 123456789012
and customer K0002 has a Contract Type that prevents adding more devices
When I send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Customer contract type does not allow to add more Devices"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Should not create Lync Option if limit of devices for Phone Extension is reached
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as Admin
and customer K0002 has a Contract Type that prevents adding more devices on phone extension
When I send /api/customers/K0002/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Cannot add more devices to a phone extension in this contract type exception",
    "path": "phones"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Fail meaningfully when trying to create Lync Option for not existing Customer
Test setup
Given there is a LyncSite with id 500 and name Lync Site
and there is a Phone Extension with extension number 201
and display name PhoneExtension
which has Inbound Trunk Number +48 (22) 1111-119
and there is a Device Type LYNC
and there is a Device Type MSTEAMS
Given I am authenticated as Admin
When I send /api/customers/K0404/targets/phone-extensions/201/lync as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "lyncSite",
    "href": "/api/customers/K0002/lync/sites/500"
  }, {
    "rel": "inboundTrunkNumber",
    "href": "/api/customers/K0002/targets/phone-extensions/201/inbound-trunk-numbers/0048.22.1111-119"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
And Content-Type header should be application/api-problem+json
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"
}