Api >

Service Portal REST API

PUT changes timeout
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
Then I should receive HTTP/1.1 204 No Content
When I send request /api/customers/K0002/targets/group-services/345/timeout
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
PUT changes timeout (use targets)
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
Then I should receive HTTP/1.1 204 No Content
When I send request /api/customers/K0002/targets/group-services/345/timeout
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
PUT disables timeout with NO_ACTION
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/NO_ACTION"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 0
  }]
}
Then I should receive HTTP/1.1 204 No Content
When I send request /api/customers/K0002/targets/group-services/345/timeout
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/NO_ACTION"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 0
  }]
}
PUT doesn't allow set negative Timeout Delay
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": -13
  }]
}
Then I should receive HTTP/1.1 400 Bad Request and application/api-problem+json with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "must be greater than or equal to 0",
    "path": "timeout",
    "value": "-13"
  }]
}
PUT doesn't allow assign destinationOnTimeout while disabling timeout
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 0
  }]
}
Then I should receive HTTP/1.1 400 Bad Request and application/api-problem+json with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "TimeoutDelay need to be greater than 0 when destinationOnTimeout is provided"
  }]
}
PUT doesn't allow to assign destinationOnTimeout to NO_ACTION for enabled timeout
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/NO_ACTION"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "When destinationOnTimeout is not provided, TimeoutDelay need to be 0"
  }]
}
PUT fails disable timeout with BUSY destination
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 0
  }]
}
Then I should receive HTTP/1.1 400 Bad Request With following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "TimeoutDelay need to be greater than 0 when destinationOnTimeout is provided"
  }]
}
PUT changes destination to other valid when timeout is already enabled
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
And it has Timeout Delay set to 2 and Destination On Timeout point to BUSY
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/HANGUP"
  }]
}
Then I should receive HTTP/1.1 204 No Content
When I send request /api/customers/K0002/targets/group-services/345/timeout
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 2
  }]
}
PUT changes timeout to other enabled when destination is valid
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
And it has Timeout Delay set to 2 and Destination On Timeout point to BUSY
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "timeoutDelay",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 204 No Content
When I send request /api/customers/K0002/targets/group-services/345/timeout
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 4
  }]
}
PUT doesn't accepts invalid forward destination
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/REPEAT"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 400 Bad Request With following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "This destination cannot be assigned to this service"
  }]
}
Admin cannot update destination on timeout with link to another Customer's destination
Given I am authenticated as Admin
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0003/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 400 Bad Request With following body:
{
  "errors": [{
    "message": "Destination On Timeout must belong to the owner of Group Service",
    "path": "destinationOnTimeout"
  }]
}
Customer cannot update destination on timeout with link to another Customer's destination
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0003/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 4
  }]
}
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"
}
Cannot update destination on timeout with link to missing Destination
Given I am authenticated as Customer K0002
And there is a Group Service with Service Number 345
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/phone-extensions/404"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 404 Not Found With following body:
{
  "detail": "Extension with extension number 404 has not been found",
  "title": "Extension not found",
  "described_by": "http://api.nfon.net/probs/extension-not-found"
}
Cannot update Destination On Timeout for missing Group Service
Given I am authenticated as Customer K0002
When I send /api/customers/K0002/targets/group-services/404/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "title": "Group not found",
  "detail": "Group with serviceNumber 404 not found",
  "described_by": "http://api.nfon.net/probs/group-not-found"
}
Missing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
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"
}
Customer should not be able to get another Customer's Group's Destination On Timeout
Given I am authenticated as Customer K0003
When I send /api/customers/K0002/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot update Group Service Timeout of Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
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 update Group Service Timeout of Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/group-services/345/timeout as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "destinationOnTimeout",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "timeoutDelay",
    "value": 24
  }]
}
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"
}