Api >

Service Portal REST API

POST assigns Function Key to destination
Given I am authenticated as customer K0002
And there is PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body:
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
And when /api/customers/K0002/targets/phone-extensions/201/function-keys/1
I'll get
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
POST assigns Function Key to speeddial (using new target reference)
Given I am authenticated as customer K0002
And there is PhoneExtension with extensionNumber 201
When I send /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body:
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/external/0048.22.100-456"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "SPEEDDIAL"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
And when /api/customers/K0002/targets/phone-extensions/201/function-keys/1
I'll get
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/external/0048.22.100-456?id=9"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "SPEEDDIAL"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
POST assigns Function Key to function
Given I am authenticated as customer K0002
And there is PhoneExtension with extensionNumber 201
When I send /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }, {
    "name": "displayName",
    "value": "Invoke Function"
  }, {
    "name": "functionCode",
    "value": "*80"
  }]
}
Then response code should be equal HTTP/1.1 201 Created
Given I am authenticated as customer K0002
And than /api/customers/K0002/targets/phone-extensions/201/function-keys/1 will return
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }, {
    "name": "displayName",
    "value": "Invoke Function"
  }, {
    "name": "functionCode",
    "value": "*80"
  }]
}
Missing Customer
Given I am authenticated as Admin
And there is no customer K404
When I create resource with /api/customers/K0404/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
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"
}
Missing Extension
Given I am authenticated as customer K0002
And I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
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 201 has not been found",
  "described_by": "http://api.nfon.net/probs/extension-not-found"
}
Assigning already assigned Function Key to destination
Given I am authenticated as customer K0002
And there is PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405
And there is PhoneExtension with Id 406
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
Given I am authenticated as customer K0002
Then I try to assign same function key again /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body:
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John2"
  }]
}
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": "Function Key assignment already assigned",
  "detail": "Extension 201 has already defined assignment for key 1",
  "described_by": "http://api.nfon.net/probs/function-key-assignment-already-assigned"
}
Should not assign Function Key with invalid keyNumber
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1410
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
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:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "Invalid value for keyNumber",
    "detailMessage": "Value of keyNumber should be between 0 and 1023 but 1410 was provided",
    "path": "keyNumber",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Should not assign Function Key with invalid type
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "INVALID"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Unknown enum value. Allowed values: [SPEEDDIAL, MONITOR, INTERCOM, SERVICE, FUNCTION_CODE]",
    "path": "type",
    "value": "INVALID"
  }]
}
Should not assign Function Key if target is not provided when required (for types SERVICE, MONITOR, INTERCOM and SPEEDDIAL)
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Target is required for this type",
    "path": "target"
  }]
}
Should not assign Function Key if target is empty when required (for types SERVICE, MONITOR, INTERCOM and SPEEDDIAL)
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": ""
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Target is required for this type",
    "path": "target"
  }]
}
Should not assign Function Key if function code is not provided when required (for type FUNCTION_CODE)
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Function code is required for this type",
    "path": "functionCode"
  }]
}
Should not assign Function Key if function code is empty when required (for type FUNCTION_CODE)
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }, {
    "name": "functionCode",
    "value": ""
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Function code is required for this type",
    "path": "functionCode"
  }]
}
Should not assign Function Key if function code is provided with incorrect type (for types SERVICE, MONITOR, INTERCOM and SPEEDDIAL)
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "functionCode",
    "value": "123"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Function code is not allowed for type MONITOR",
    "path": "functionCode"
  }]
}
Should not assign Function Key if target is provided with incorrect type (for type FUNCTION_CODE)
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }, {
    "name": "functionCode",
    "value": "123"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Target is not allowed for type FUNCTION_CODE",
    "path": "target"
  }]
}
Should not assign Function Key if Phone Extension target is not of types MONITOR or INTERCOM
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "SERVICE"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "For given target [PHONEEXTENSION] the type of Key Assignment should be: [MONITOR, INTERCOM]"
  }]
}
Should not assign Function Key if Service target is not of type SERVICE
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 701
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/queue-services/701"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "For given target [QUEUE] the type of Key Assignment should be: [SERVICE]"
  }]
}
Should not assign Function Key if Speed Dial target has incorrect phone number format (using new target reference)
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/external/invalid"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "SPEEDDIAL"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "title": "Incorrect Phone Number",
  "detail": "Phone Number [invalid] is incorrect",
  "described_by": "http://api.nfon.net/probs/incorrect-phone-number"
}
Should not assign Function Key if SPEEDDIAL type has invalid target
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 701
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "SPEEDDIAL"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "title": "Invalid resource type",
  "detail": "Resource at /api/customers/K0002 is of incorrect type",
  "described_by": "http://api.nfon.net/probs/invalid-resource-type"
}
Should not assign Function Key to function if function code is invalid
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }, {
    "name": "functionCode",
    "value": "+123"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Function code has incorrect format",
    "path": "functionCode",
    "value": "+123"
  }]
}
Should not assign Function Key if Service target is of not allowed type
Given I am authenticated as customer K0002
And there is a PhoneExtension with extensionNumber 201
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }]
}
Then response code should be equal HTTP/1.1 400 Bad Request
And response should look like:
{
  "errors": [{
    "message": "Target BUSY is not allowed to be assigned to Function Key. It should be one of: [CONFERENCE, GROUP, IVR, PHONEEXTENSION, QUEUE, SKILL, TIMECONTROL]",
    "path": "target"
  }]
}
Customer cannot assign Function Keys to Customer's Phone Extension
Given I am authenticated as Customer K0003
And there is PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body:
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0002/targets/phone-extensions/201"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
Then I should get HTTP/1.1 403 Forbidden
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Admin cannot assign destination of another Customer
Gien I am authenticated as Admin
And there is PhoneExtension with extensionNumber 201
And there is PhoneExtension with Id 405 which is assigned to Customer K0003
When I create resource with /api/customers/K0002/targets/phone-extensions/201/function-keys
As application/json; charset=UTF-8
With following body:
{
  "links": [{
    "rel": "target",
    "href": "/api/customers/K0003/targets/phone-extensions/405"
  }],
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "MONITOR"
  }, {
    "name": "displayName",
    "value": "Call John"
  }]
}
Then I should get HTTP/1.1 400 Bad Request
{
  "errors": [{
    "message": "Target does not belong to Customer K0002",
    "path": "target"
  }]
}
System Integrator cannot assign Function Key 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/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }, {
    "name": "displayName",
    "value": "Invoke Function"
  }, {
    "name": "functionCode",
    "value": "*80"
  }]
}
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 assign Function Key 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/function-keys
As application/json; charset=UTF-8
With following body
{
  "data": [{
    "name": "keyNumber",
    "value": 1
  }, {
    "name": "type",
    "value": "FUNCTION_CODE"
  }, {
    "name": "displayName",
    "value": "Invoke Function"
  }, {
    "name": "functionCode",
    "value": "*80"
  }]
}
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"
}