Api >

Service Portal REST API

Should update an IVR Service
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
And there is announcement with id 13 When I send /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "links": [{
    "rel": "announcement",
    "href": "/api/customers/K0002/announcements/13"
  }],
  "data": [{
    "name": "displayName",
    "value": "new display name"
  }, {
    "name": "extensionNumber",
    "value": "666"
  }, {
    "name": "interpretUnknownAsExtension",
    "value": true
  }, {
    "name": "maxNumberOfDigits",
    "value": 5
  }]
}
Then the response code should be equal HTTP/1.1 204 No Content
/api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "links": [{
    "rel": "announcement",
    "href": "/api/customers/K0002/announcements/13"
  }],
  "data": [{
    "name": "displayName",
    "value": "new display name"
  }, {
    "name": "extensionNumber",
    "value": "666"
  }, {
    "name": "interpretUnknownAsExtension",
    "value": true
  }, {
    "name": "maxNumberOfDigits",
    "value": 5
  }]
}
Should not update IVR Service using a displayName that contains invalid characters
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "displayName",
    "value": "invalid display=name"
  }]
}
Then the response code should be equal HTTP/1.1 400 Bad Request And the response should look like:
{
  "errors": [{
    "message": "Display name should not contain these characters: & $ ! ? = | \" { }",
    "path": "displayName",
    "value": "invalid display=name"
  }]
}
Should not update IVR Service using a displayName with invalid length
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "displayName",
    "value": "this is a way, way, way, way, way, way, way, way, way to long displayName"
  }]
}
Then the response code should be equal HTTP/1.1 400 Bad Request And the response should look like:
{
  "errors": [{
    "message": "Display name should have a length between 1 and 50 characters",
    "path": "displayName",
    "value": "this is a way, way, way, way, way, way, way, way, way to long displayName"
  }]
}
Should not update IVRService using an extension number with invalid format
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "extensionNumber",
    "value": "0123"
  }]
}
Then the response code should be equal HTTP/1.1 400 Bad Request
And the response should look like:
{
  "errors": [{
    "message": "Invalid extension number format. Must not start with the dial-out-prefix (default 0)",
    "path": "extensionNumber",
    "value": "0123"
  }]
}
Should not update IVR Service using too long extension number
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "extensionNumber",
    "value": "12345678901234567890123456789"
  }]
}
Then the response code should be equal HTTP/1.1 400 Bad Request
And the response should look like:
{
  "errors": [{
    "message": "Extension number length should not exceed 20 characters",
    "path": "extensionNumber",
    "value": "12345678901234567890123456789"
  }]
}
Should not update IVRService using duplicate extension number
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
Given there is already an extension with extension number 1234 When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "extensionNumber",
    "value": "1234"
  }]
}
Then the response code should be equal HTTP/1.1 400 Bad Request
And the response should look like:
{
  "errors": [{
    "message": "Extension number is not unique.",
    "path": "extensionNumber",
    "value": "1234"
  }]
}
Should allow to set announcement to null
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
Given there is Announcement with id 13 That is already assigned to IVR Service When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "links": [{
    "rel": "announcement",
    "href": null
  }]
}
Then the response code should be equal HTTP/1.1 204 No Content
/api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "links": [{
    "rel": "announcement",
    "href": null
  }]
}
Should not allow to set max number of digits from the outside of allowed range
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "maxNumberOfDigits",
    "value": 11
  }]
}
Then the response code should be HTTP/1.1 400 Bad Request
And the response body should look like:
{
  "errors": [{
    "message": "maxNumberOfDigits value should be between 1 and 10",
    "path": "maxNumberOfDigits",
    "value": 11
  }]
}
Should not allow to set max number of digits to value lower than the length of the longest currently assigned number
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
Given the IVR Service max number of digits is 5 And the key assignment which assigns 1234 to Phone Extension with id 1000 When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "maxNumberOfDigits",
    "value": 3
  }]
}
Then the response code should be HTTP/1.1 400 Bad Request
And the response should look like:
{
  "errors": [{
    "message": "There is assigned number longer than provided value",
    "path": "maxNumberOfDigits",
    "value": 3
  }]
}
Should not allow to set max number of digits to 1 when there already exist Key Assigned to number 12
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
Given the IVR Service max number of digits is 2 And the key assignment which assigns 12 to Phone Extension with id 1000 When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "maxNumberOfDigits",
    "value": 1
  }]
}
Then the response code should be HTTP/1.1 400 Bad Request And the response should look like:
{
  "errors": [{
    "message": "There is assigned number longer than provided value",
    "path": "maxNumberOfDigits",
    "value": 1
  }]
}
Should convert Key Assignments to OLD model while changing maxNumberOfDigitsTo 1
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
Given the IVR Service max number of digits is 2 And the key assignment which assigns 1 to Phone Extension with id 1000 When I update a resource at /api/customers/K0002/targets/ivr-services/29 as application/json; charset=UTF-8 :
{
  "data": [{
    "name": "maxNumberOfDigits",
    "value": 1
  }]
}
Then the response code should be HTTP/1.1 204 No Content
/api/customers/K0002/targets/ivr-services/29/key-assignments/1
Should return HTTP/1.1 200 OK
Missing Customer
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as Admin
When I update a resource at /api/customers/K404/targets/ivr-services/29 as application/json; charset=UTF-8 :
{}
Then the response code should be HTTP/1.1 404 Not Found with following body:
{
  "title": "Customer not found",
  "detail": "Customer with identifier K404 has not been found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
Customer can't change resource which belongs to another customer
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as customer K0002
When I update a resource at /api/customers/K0003/targets/ivr-services/29 as application/json; charset=UTF-8 :
{}
Then the response code should be 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"
}
System Integrator cannot update IVR Service of Customer, that does not belong to him
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/targets/ivr-services/29 as application/json; charset=utf-8
and following body
{}
Then I should receive HTTP/1.1 403 Forbidden
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Operator cannot update IVR Service of Customer, that does not belong to him
Test setup
Given there is an IVR Service with service number 29
And display name IVR Service
And extension 29
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/ivr-services/29 as application/json; charset=utf-8
and following body
{}
Then I should receive HTTP/1.1 403 Forbidden
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}