Api >

Service Portal REST API

Should create a skill service member
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and there is a phone extension with number 712
and I am authenticated as customer K0002
When I try to add member /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/712"
  }],
  "data": [{
    "name": "skillLevel",
    "value": 9
  }]
}
Then I should receive HTTP/1.1 201 Created
with http://localhost:9998/api/customers/K0002/targets/skill-services/345/members/712 and body:
{
  "href": "/api/customers/K0002/targets/skill-services/345/members/712"
}
Given I am authenticated as customer K0002
When I ask for skill member /api/customers/K0002/targets/skill-services/345/members/712
Then I should receive HTTP/1.1 200 OK
And Content-Type header should be application/vnd.collection.next+json
with following body:
{
  "href": "/api/customers/K0002/targets/skill-services/345/members/712",
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/712"
  }],
  "data": [{
    "name": "skillLevel",
    "value": 9
  }, {
    "name": "extensionDisplayName",
    "value": "Extension #712"
  }, {
    "name": "extensionNumber",
    "value": "712"
  }, {
    "name": "skillDisplayName",
    "value": "skill name"
  }, {
    "name": "skillServiceNumber",
    "value": 345
  }, {
    "name": "enabled",
    "value": true
  }]
}
Should create a skill service member and set default skill level
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and there is a phone extension with number 712
and I am authenticated as customer K0002
When I try to add member /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/712"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
When I ask for skill member /api/customers/K0002/targets/skill-services/345/members/712
Then I should receive HTTP/1.1 200 OK
And Content-Type header should be application/vnd.collection.next+json
with following body:
{
  "href": "/api/customers/K0002/targets/skill-services/345/members/712",
  "data": [{
    "name": "skillLevel",
    "value": 1
  }]
}
Cannot set extensionDisplayName field during creation
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and there is a phone extension with number 712
and I am authenticated as customer K0002
When I try to add member /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "extensionDisplayName",
    "value": "new name"
  }],
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/712"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "A readonly field is being modified with different value.",
    "path": "extensionDisplayName",
    "value": "new name"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot set incorrect skill level
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and there is a phone extension with number 712
and I am authenticated as customer K0002
When I try to add member /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "skillLevel",
    "value": 13
  }],
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/712"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "skillLevel should be between 1 and 10",
    "path": "skillLevel",
    "value": 13
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create member without extension
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and I am authenticated as customer K0002
When I try to add member /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "PhoneExtension is required",
    "path": "phoneExtension",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Should not assign already assigned member
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and there is a phone extension with number 712
and I am authenticated as customer K0002
When I try to add member /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/712"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
When I try to add member again /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/712"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Skill member already exists",
  "detail": "There is skill member for phone extension: /api/customers/K0002/targets/phone-extensions/712",
  "described_by": "http://api.nfon.net/probs/skill-member-already-exists"
}
Missing Skill
Given there is no skill service with 404 identifier and I am authenticated as customer K0002
When I try to add member to not existing a skill /api/customers/K0002/targets/skill-services/404/members
as application/json; charset=UTF-8
with following body:
{
  "data": []
}
Then I should receive HTTP/1.1 404 Not Found
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Skill service not found",
  "detail": "Skill service with serviceNumber 404 not found",
  "described_by": "http://api.nfon.net/probs/skill-service-not-found"
}
Missing Customer
Given I am authenticated as Admin
When I send /api/customers/K404/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "data": []
}
Then I should receive HTTP/1.1 404 Not Found
And Content-Type header should be application/api-problem+json
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 should not be able to add members to another Customer's skill
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and I am authenticated as Customer K0003
When I try to add member to not existing a skill /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "data": []
}
Then I should receive HTTP/1.1 403 Forbidden
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Customer should not be able to add skill member with Phone Extension of another Customer
Given there is a skill service
  • with name skill name
  • with service number 345
  • and asterisk extension number 576

and there is an another customer with externalIdentifier K0003
and there is a phone extension with number 712 for K0003
and I am authenticated as customer K0002
When I try to add member with extension that belongs to another customer /api/customers/K0002/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0003/targets/phone-extensions/712"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
And Content-Type header should be application/api-problem+json
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 Skill Service Member for Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0003/targets/phone-extensions/712"
  }]
}
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 Skill Service Member for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/skill-services/345/members
as application/json; charset=UTF-8
with following body:
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0003/targets/phone-extensions/712"
  }]
}
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"
}