Api >

Service Portal REST API

POST creates an IVR Service
Given I am authenticated as customer K0002
And there is announcement with id 13
And a Forward Destination with id 37
When I create a resource at /api/customers/K0002/targets/ivr-services using application/json; charset=UTF-8

With following body
{
  "links": [{
    "rel": "announcement",
    "href": "/api/customers/K0002/announcements/13"
  }],
  "data": [{
    "name": "displayName",
    "value": "New IVR Service"
  }, {
    "name": "extensionNumber",
    "value": "579"
  }, {
    "name": "interpretUnknownAsExtension",
    "value": true
  }, {
    "name": "maxNumberOfDigits",
    "value": 3
  }]
}

Then the response code should be equal HTTP/1.1 201 Created
And the response should look like
{
  "href": "/api/customers/K0002/targets/ivr-services/0"
}
Request /api/customers/K0002/targets/ivr-services/0
Should result:
{
  "links": [{
    "rel": "announcement",
    "href": "/api/customers/K0002/announcements/13"
  }],
  "data": [{
    "name": "displayName",
    "value": "New IVR Service"
  }, {
    "name": "extensionNumber",
    "value": "579"
  }, {
    "name": "interpretUnknownAsExtension",
    "value": true
  }, {
    "name": "maxNumberOfDigits",
    "value": 3
  }]
}
Should not create IVR Service without a displayName
Given I am authenticated as customer K0002
When I create a resource at /api/customers/K0002/targets/ivr-services
With following application/json; charset=UTF-8 body
{
  "data": [{
    "name": "extensionNumber",
    "value": "579"
  }]
}
Then the response code should be equal HTTP/1.1 400 Bad Request
And the response should look like:
{
  "errors": [{
    "message": "Display name is missing",
    "path": "displayName"
  }]
}
Should not create IVR Service using a displayName that contains invalid characters
Given I am authenticated as Customer K0002
When I create a resource at /api/customers/K0002/targets/ivr-services
using application/json; charset=UTF-8 with following body
{
  "data": [{
    "name": "displayName",
    "value": "invalid display=name"
  }, {
    "name": "extensionNumber",
    "value": "579"
  }]
}

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 create IVR Service using a displayName with invalid length
Given I am authenticated as Customer K0002
When I create a resource at /api/customers/K0002/targets/ivr-services using application/json; charset=UTF-8
with following body
{
  "data": [{
    "name": "displayName",
    "value": "this is a way, way, way, way, way, way, way, way, way to long displayName"
  }, {
    "name": "extensionNumber",
    "value": "579"
  }]
}

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 create an IVR Service without extension
Given I am authenticated as Customer K0002
When I create a resource at /api/customers/K0002/targets/ivr-services using application/json; charset=UTF-8
with following body
{
  "data": [{
    "name": "displayName",
    "value": "New IVR Service"
  }]
}
Then the response code should be equal HTTP/1.1 201 Created
And the response should look like:
{
  "href": "/api/customers/K0002/targets/ivr-services/0"
}
Request /api/customers/K0002/targets/ivr-services/0
Should result:
{
  "data": [{
    "name": "displayName",
    "value": "New IVR Service"
  }]
}
Should not create IVR Service using an extension number with invalid format
Given I am authenticated as Customer K0002
When I create a resource at /api/customers/K0002/targets/ivr-services using application/json; charset=UTF-8 with following body
{
  "data": [{
    "name": "displayName",
    "value": "New IVR Service"
  }, {
    "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 create IVR Service using too long extension number
Given I am authenticated as Customer K0002
When I create a resource at /api/customers/K0002/targets/ivr-services using application/json; charset=UTF-8 with following body
{
  "data": [{
    "name": "displayName",
    "value": "New IVR Service"
  }, {
    "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 create IVR Service using duplicate extension number
Given I am authenticated as Customer K0002
Given there is already an extension with extension number 1234 When I create a resource at /api/customers/K0002/targets/ivr-services with following application/json; charset=UTF-8 body
{
  "data": [{
    "name": "displayName",
    "value": "New IVR Service"
  }, {
    "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 not create an IVR Service with a given announcement of a different type than General Announcement
Given I am authenticated as Customer K0002
Given there is an announcement with id 131 and type MUSIC_ON_HOLD When I create a resource at /api/customers/K0002/targets/ivr-services using application/json; charset=UTF-8 with following body
{
  "links": [{
    "rel": "announcement",
    "href": "/api/customers/K0002/announcements/131"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "extensionNumber",
    "value": "579"
  }]
}
Then the response code should be equal HTTP/1.1 400 Bad Request And the response should look like:
{
  "errors": [{
    "message": "Expected announcement to be type of [GENERAL_ANNOUNCEMENT] but was [MUSIC_ON_HOLD]",
    "path": "announcement"
  }]
}
Missing Customer
Given I am authenticated as Admin
/api/customers/K404/targets/ivr-services using application/json; charset=UTF-8

With following body
{}

Then the response code should be equal HTTP/1.1 404 Not Found
And the response should look like
{
  "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 create resource which belongs to another customer
Given I am authenticated as customer K0002
/api/customers/K0003/targets/ivr-services using application/json; charset=UTF-8

With following body
{}

Then the response code should be equal HTTP/1.1 403 Forbidden
And the response should look like
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot create IVR Services for Customer, that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/targets/ivr-services as application/json; charset=UTF-8
with 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 create IVR Services for Customer, that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/ivr-services as application/json; charset=UTF-8
with 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"
}