Api >

Service Portal REST API

POST creates Time Control Service
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }, {
    "rel": "timezone",
    "href": "/api/time-zones/Africa.Juba"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "extensionNumber",
    "value": "345"
  }, {
    "name": "evaluationStrategy",
    "value": "ALLOW"
  }, {
    "name": "fromDay",
    "value": "TUESDAY"
  }, {
    "name": "fromTimeOfDay",
    "value": "02:34 AM"
  }, {
    "name": "toDay",
    "value": "SUNDAY"
  }, {
    "name": "toTimeOfDay",
    "value": "06:06 AM"
  }, {
    "name": "referralAllowed",
    "value": ["Apr 30, 2011", "Feb 26, 2012", "Jun 01, 2013"]
  }, {
    "name": "referralDenied",
    "value": ["Jan 31, 2012", "Feb 29, 2016"]
  }]
}
Then I should receive HTTP/1.1 201 Created
with http://localhost:9998/api/customers/K0002/targets/time-control-services/0 and body:
{
  "href": "/api/customers/K0002/targets/time-control-services/0"
}

Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services/0
Then I should receive HTTP/1.1 200 OK
{
  "href": "/api/customers/K0002/targets/time-control-services/0",
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }, {
    "rel": "inboundTrunkNumbers",
    "href": "/api/customers/K0002/targets/time-control-services/0/inbound-trunk-numbers"
  }, {
    "rel": "availableDestinations",
    "href": "/api/customers/K0002/targets/time-control-services/available-destinations"
  }, {
    "rel": "timezone",
    "href": "/api/time-zones/Africa.Juba"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "extensionNumber",
    "value": "345"
  }, {
    "name": "evaluationStrategy",
    "value": "ALLOW"
  }, {
    "name": "fromDay",
    "value": "TUESDAY"
  }, {
    "name": "fromTimeOfDay",
    "value": "02:34 AM"
  }, {
    "name": "toDay",
    "value": "SUNDAY"
  }, {
    "name": "toTimeOfDay",
    "value": "06:06 AM"
  }, {
    "name": "referralAllowed",
    "value": ["Apr 30, 2011", "Feb 26, 2012", "Jun 01, 2013"]
  }, {
    "name": "referralDenied",
    "value": ["Jan 31, 2012", "Feb 29, 2016"]
  }]
}
Cannot create Time Control Service with missing displayName
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": []
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Display name is missing",
    "path": "displayName"
  }]
}
Cannot create Time Control Service with missing displayName (using targets href)
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": []
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Display name is missing",
    "path": "displayName"
  }]
}
Cannot create Time Control Service with missing destinationIfAllowed link
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfAllowed is required",
    "path": "destinationIfAllowed",
    "value": ""
  }]
}
Cannot create Time Control Service with missing destinationIfAllowed link (using targets href)
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfAllowed is required",
    "path": "destinationIfAllowed",
    "value": ""
  }]
}
Cannot create Time Control Service with missing destinationIfDenied link
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfDenied is required",
    "path": "destinationIfDenied",
    "value": ""
  }]
}
Cannot create Time Control Service with missing destinationIfDenied link (using target hrefs)
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfDenied is required",
    "path": "destinationIfDenied",
    "value": ""
  }]
}
Should not create a Time Control Service using a displayName that contains invalid characters
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "is this new name?"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "errors": [{
    "message": "Display name should not contain these characters: & $ ! ? = | \" { }",
    "path": "displayName",
    "value": "is this new name?"
  }]
}
Should not create a Time Control Service using a displayName that contains invalid characters (using targets href)
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "is this new name?"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "errors": [{
    "message": "Display name should not contain these characters: & $ ! ? = | \" { }",
    "path": "displayName",
    "value": "is this new name?"
  }]
}
Should not create a Time Control Service using a displayName with invalid length
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "this is a way, way, way, way, way, way, way, way, way to long displayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "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 a Time Control Service without extension number
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services/0
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "data": []
}
Cannot create a Time Control Service using an extension number with invalid format
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "extensionNumber",
    "value": "0123"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Invalid extension number format. Must not start with the dial-out-prefix (default 0)",
    "path": "extensionNumber",
    "value": "0123"
  }]
}
Should not create a Time Control Service using too long extension number
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "extensionNumber",
    "value": "12345678901234567890123456789"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Extension number length should not exceed 20 characters",
    "path": "extensionNumber",
    "value": "12345678901234567890123456789"
  }]
}
Should not create a Time Control Service using duplicate extension number
Given I am authenticated as customer K0002
and there is already an extension with extension number 12345 When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "extensionNumber",
    "value": "12345"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Extension number is not unique.",
    "path": "extensionNumber",
    "value": "12345"
  }]
}
Should not create a Time Control Service with invalid Evaluation Strategy
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "evaluationStrategy",
    "value": "INVALID"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Unknown enum value. Allowed values: [AUTO, ALLOW, DENY]",
    "path": "evaluationStrategy",
    "value": "INVALID"
  }]
}
Should not create a Time Control Service with invalid Timezone
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }, {
    "rel": "timezone",
    "href": "/api/time-zones/invalid"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "timezone must be given in an 'area/location' format",
    "path": "timezone",
    "value": "invalid"
  }]
}
Should not create a Time Control Service with valid but not existing Timezone
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }, {
    "rel": "timezone",
    "href": "/api/time-zones/abc.def"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "timezone '/api/time-zones/abc.def' not found",
    "path": "timezone",
    "value": "abc.def"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Should not create a Time Control Service with invalid From Day
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "fromDay",
    "value": "invalid"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Unknown enum value. Allowed values: [MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY]",
    "path": "fromDay",
    "value": "invalid"
  }]
}
Should not create a Time Control Service with invalid From Time Of Day
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "fromTimeOfDay",
    "value": "11:35 AMxyz"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "fromTimeOfDay must be in the format 'hh:mm AM/PM'",
    "path": "fromTimeOfDay",
    "value": "11:35 AMxyz"
  }]
}
Should not create a Time Control Service with incorrect referral date
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "referralAllowed",
    "value": ["not a date"]
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "referral date must be in the format 'MMM dd, yyyy'",
    "path": "referralAllowed",
    "value": "not a date"
  }]
}
Should not create a Time Control Service with duplicated referral date
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "referralDenied",
    "value": ["Oct 21, 2015", "Oct 21, 2015"]
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "duplicate referral date",
    "path": "referralDenied",
    "value": "Oct 21, 2015"
  }]
}
Should not create a Time Control Service with same date in allowed and denied referrals
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }, {
    "name": "referralDenied",
    "value": ["Oct 21, 2015"]
  }, {
    "name": "referralAllowed",
    "value": ["Oct 21, 2015"]
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Cannot specify the same date for allowed and denied referral at the same time",
    "path": "referralAllowed",
    "value": "Oct 21, 2015"
  }]
}
Should not create a Time Control Service with destinationIfAllowed null link
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": null
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfAllowed cannot be null",
    "path": "destinationIfAllowed",
    "value": null
  }]
}
Should not create a Time Control Service with destinationIfDenied null link
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": null
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfDenied cannot be null",
    "path": "destinationIfDenied",
    "value": null
  }]
}
Should not create a Time Control Service with destinationIfAllowed link of type NO_ACTION
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/NO_ACTION"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfAllowed cannot point to source and should be one of: [BUSY, CONFERENCE, EFAX, FRONTDESK, GROUP, HANG_UP, IVR, PHONEEXTENSION, QUEUE, ROUTINGPREFIX, SKILL, TIMECONTROL, VOICEMAIL]",
    "path": "destinationIfAllowed",
    "value": "NOOP"
  }]
}
Should not create a Time Control Service with destinationIfAllowed link of type REPEAT
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/REPEAT"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfAllowed cannot point to source and should be one of: [BUSY, CONFERENCE, EFAX, FRONTDESK, GROUP, HANG_UP, IVR, PHONEEXTENSION, QUEUE, ROUTINGPREFIX, SKILL, TIMECONTROL, VOICEMAIL]",
    "path": "destinationIfAllowed",
    "value": "REPEAT"
  }]
}
Should not create a Time Control Service with destinationIfAllowed link of type PHONEBOOK
Given I am authenticated as customer K0002
and the next Phone Extension ID is 1000
and there is a Phone Book with number +48 (123) 123123 name phone book
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/phone-books/1000"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfAllowed cannot point to source and should be one of: [BUSY, CONFERENCE, EFAX, FRONTDESK, GROUP, HANG_UP, IVR, PHONEEXTENSION, QUEUE, ROUTINGPREFIX, SKILL, TIMECONTROL, VOICEMAIL]",
    "path": "destinationIfAllowed",
    "value": "PHONEBOOK"
  }]
}
Should not create a Time Control Service with destinationIfAllowed link of type DIRECTDIAL
Given I am authenticated as customer K0002
and the next Direct Dial ID is 2000
and there is a Direct Dial with number +48 (10) 1234 and extension 777
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/direct-dial/0048101234"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "destinationIfAllowed cannot point to source and should be one of: [BUSY, CONFERENCE, EFAX, FRONTDESK, GROUP, HANG_UP, IVR, PHONEEXTENSION, QUEUE, ROUTINGPREFIX, SKILL, TIMECONTROL, VOICEMAIL]",
    "path": "destinationIfAllowed",
    "value": "DIRECTDIAL"
  }]
}
Should create a Time Control Service with destinationIfAllowed link of type EFAX
Given I am authenticated as customer K0002
and the next Virtual Fax Extension ID is 2000
and there is an Virtual Fax with extension 123
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/virtual-fax-extensions/123"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Should create a Time Control Service with destinationIfAllowed link of type VOICEMAIL
Given I am authenticated as customer K0002
and there is a Voice Mail for Phone Extension with ID 2000
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/phone-extensions/777"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Should create a Time Control Service with destinationIfAllowed link of type IVR
Given I am authenticated as customer K0002
and the next IVR Service ID is 2000
and there is a IVR Service with service number 555
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/ivr-services/555"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Should create a Time Control Service with destinationIfAllowed link of type GROUP
Given I am authenticated as customer K0002
and the next Group Service ID is 2000
and there is a Group Service with service number 555
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/group-services/555"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Should create a Time Control Service with destinationIfAllowed link of type QUEUE
Given I am authenticated as customer K0002
and the next Queue Service ID is 2000
and there is a Queue Service with service number 555
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/queue-services/555"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Should create a Time Control Service with destinationIfAllowed link of type SKILL
Given I am authenticated as customer K0002
and the next Conference Service ID is 2000
and there is a Conference Service with service number 555
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/conference-services/555"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Should create a Time Control Service with destinationIfAllowed link of type CONFERENCE
Given I am authenticated as customer K0002
and the next Skill Service ID is 2000
and there is a Skill Service with service number 555
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/skill-services/555"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 201 Created
Should not allow to create a Time Control Service with null To Day
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "displayName",
    "value": "displayName"
  }, {
    "name": "toDay",
    "value": null
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "toDay cannot be null",
    "path": "toDay",
    "value": null
  }]
}
Should not allow to create a Time Control Service with null To Time Of Day
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "displayName",
    "value": "displayName"
  }, {
    "name": "toTimeOfDay",
    "value": null
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "toTimeOfDay cannot be null",
    "path": "toTimeOfDay",
    "value": null
  }]
}
Should not allow to create a Time Control Service with null Referral Date
Given I am authenticated as customer K0002
When I send /api/customers/K0002/targets/time-control-services as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "displayName",
    "value": "displayName"
  }, {
    "name": "referralAllowed",
    "value": [null]
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "referral date cannot be null",
    "path": "referralAllowed",
    "value": null
  }]
}
Cannot create a Time Control Service with non existing destinationIfAllowed
Given I am authenticated as Customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/phone-extensions/404"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
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"
}
Customer cannot create a Time Control Service with destinationIfAllowed set to another Customer's destination
Given I am authenticated as Customer K0002
and there is another Customer K0003
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0003/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
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"
}
Admin cannot create a Time Control Service with destinationIfAllowed set to another Customer's destination
Given I am authenticated as Admin
and there is another Customer K0003
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0003/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Destination must belong to the owner of Time Control Service",
    "path": "destinationIfAllowed"
  }]
}
Cannot create a Time Control Service with non existing destinationIfDenied
Given I am authenticated as Customer K0002
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/phone-extensions/404"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
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"
}
Customer cannot create a Time Control Service with destinationIfDenied set to another Customer's destination
Given I am authenticated as Customer K0002
and there is another Customer K0003
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0003/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
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"
}
Admin cannot create a Time Control Service with destinationIfDenied set to another Customer's destination
Given I am authenticated as Admin
and there is another Customer K0003
When I send /api/customers/K0002/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "destinationIfAllowed",
    "href": "/api/customers/K0002/targets/BUSY"
  }, {
    "rel": "destinationIfDenied",
    "href": "/api/customers/K0003/targets/HANGUP"
  }],
  "data": [{
    "name": "displayName",
    "value": "someDisplayName"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Destination must belong to the owner of Time Control Service",
    "path": "destinationIfDenied"
  }]
}
Admin cannot create Time Control Service for a missing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "data": []
}
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 cannot create Time Control Service for another Customer
Given I am authenticated as Customer K0002
When I send /api/customers/K0003/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "data": []
}
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"
}
System Integrator cannot create Time Control Service for Customer, that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "data": []
}
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 create Time Control Service for Customer, that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/time-control-services
as application/json; charset=UTF-8
with following body:
{
  "data": []
}
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"
}