Api >

Service Portal REST API

POST creates Customer's Speed Dial entry with only required fields
Given I am authenticated as customer K0002
And next Speed Dial entry ID will be 100
When I send /api/customers/K0002/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "SpeedDial"
  }, {
    "name": "destination",
    "value": "*554#234"
  }, {
    "name": "code",
    "value": "22"
  }]
}
Then I should receive HTTP/1.1 201 Created
with http://localhost:9998/api/customers/K0002/speed-dials/100 and following body:
{
  "href": "/api/customers/K0002/speed-dials/100"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/speed-dials/100
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/speed-dials/100",
  "links": [],
  "data": [{
    "name": "destination",
    "value": "*554#234"
  }, {
    "name": "name",
    "value": "SpeedDial"
  }, {
    "name": "code",
    "value": "22"
  }, {
    "name": "outwardDialOverwrite",
    "value": false
  }]
}
POST creates Customer's Speed Dial entry with all properties
Given I am authenticated as customer K0002
And next Speed Dial entry ID will be 100
When I send /api/customers/K0002/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "SpeedDialov"
  }, {
    "name": "destination",
    "value": "*564#234"
  }, {
    "name": "code",
    "value": "33"
  }, {
    "name": "outwardDialOverwrite",
    "value": true
  }]
}
Then I should receive HTTP/1.1 201 Created
with http://localhost:9998/api/customers/K0002/speed-dials/100 and following body:
{
  "href": "/api/customers/K0002/speed-dials/100"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/speed-dials/100
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/speed-dials/100",
  "links": [],
  "data": [{
    "name": "destination",
    "value": "*564#234"
  }, {
    "name": "name",
    "value": "SpeedDialov"
  }, {
    "name": "code",
    "value": "33"
  }, {
    "name": "outwardDialOverwrite",
    "value": true
  }]
}
Cannot create Speed Dial entry if required properties are empty
Given I am authenticated as customer K0002
When I send /api/customers/K0002/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": ""
  }, {
    "name": "destination",
    "value": ""
  }, {
    "name": "code",
    "value": ""
  }]
}
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": "value is missing",
    "path": "name",
    "value": ""
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create Speed Dial entry if name contains invalid characters
Given I am authenticated as customer K0002
When I send /api/customers/K0002/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "invalid=name"
  }, {
    "name": "destination",
    "value": "+49 (66) 1234-555"
  }]
}
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": "value has invalid characters",
    "path": "name",
    "value": "invalid=name"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create Speed Dial entry if name has invalid length
Given I am authenticated as customer K0002
When I send /api/customers/K0002/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "very long, long, long, long, long, long, long, long name"
  }, {
    "name": "destination",
    "value": "*554#234"
  }, {
    "name": "code",
    "value": "22"
  }]
}
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": "value has invalid length",
    "path": "name",
    "value": "very long, long, long, long, long, long, long, long name"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create Speed Dial entry if destination has invalid format
Given I am authenticated as customer K0002
When I send /api/customers/K0002/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "SpeedDial"
  }, {
    "name": "destination",
    "value": "()*554#234"
  }, {
    "name": "code",
    "value": "22"
  }]
}
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": "must match \"^(\\*{0,2}\\d+)?(\\#\\d+)?\"",
    "path": "destination",
    "value": "()*554#234"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Missing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "SpeedDial"
  }, {
    "name": "destination",
    "value": "*554#234"
  }, {
    "name": "code",
    "value": "22"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
{
  "detail": "Customer with identifier K0404 has not been found",
  "title": "Customer not found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
Customer should not be able to create another Customer's Speed Dial entries
Given I am authenticated as Customer K0003
When I send /api/customers/K0002/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "SpeedDial"
  }, {
    "name": "destination",
    "value": "*554#234"
  }, {
    "name": "code",
    "value": "22"
  }]
}
Then I should receive 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"
}
System Integrator should not be able to create Speed Dial entry of a Customer that he cannot manage
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "SpeedDial"
  }, {
    "name": "destination",
    "value": "*554#234"
  }, {
    "name": "code",
    "value": "22"
  }]
}
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 should not be able to create Speed Dial entries of a Customer that he cannot manage
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/speed-dials
with application/json; charset=UTF-8 and following body:
{
  "data": [{
    "name": "name",
    "value": "SpeedDial"
  }, {
    "name": "destination",
    "value": "*554#234"
  }, {
    "name": "code",
    "value": "22"
  }]
}
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"
}