Api >

Service Portal REST API

POST creates new group service member
Given I am authenticated as Customer K0002
And there is a Group Service with service number 123 and there is a Phone Extension with extension number 15
When I send /api/customers/K0002/targets/group-services/123/members with header application/json; charset=UTF-8 and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/15"
  }]
}
Then I should get HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/targets/group-services/123/members/15
And Group Service has 15 as its member
Should not create the same group service member twice
Given I am authenticated as Customer K0002
And there is a Group Service with service number 123 which has a Phone Extension with extension number 15 as its member
When I send /api/customers/K0002/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/15"
  }]
}
Then I should get HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Phone Extension 15 is already member of Group Service 123!"
  }]
}
Should not create group service member with missing link to Phone Extension
Given I am authenticated as Customer K0002
And there is a Group Service with service number 123 When I send /api/customers/K0002/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{}
Then I should get HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Value must be provided",
    "path": "phoneExtension"
  }]
}
Should not create group service member with not existing Phone Extension
Given I am authenticated as Customer K0002
And there is a Group Service with service number 123 When I send /api/customers/K0002/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/404"
  }]
}
Then I should get HTTP/1.1 404 Not Found with following body:
{
  "title": "Extension not found",
  "detail": "Extension with extension number 404 has not been found",
  "described_by": "http://api.nfon.net/probs/extension-not-found"
}
Cannot create member of missing group service
Given I am authenticated as Customer K0002
and there is no Group Service with service number 404
and there is a Phone Extension with extension number 15
When I send /api/customers/K0002/targets/group-services/404/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/15"
  }]
}
Then I should receive HTTP/1.1 404 Not Found with body including
{
  "title": "Group not found",
  "detail": "Group with serviceNumber 404 not found",
  "described_by": "http://api.nfon.net/probs/group-not-found"
}
Customer cannot create Group Service Members with link to another Customer's Phone Extension
Given I am authenticated as Customer K0002
And there is a Group Service with service number 123 and there is an another customer with externalIdentifier K0003
which has a Phone Extension with extension number 15
When I send /api/customers/K0002/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0003/targets/phone-extensions/15"
  }]
}
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 Group Service Members with link to another Customer's Phone Extension
Given I am authenticated as Admin
And there is a Group Service with service number 123 and there is an another customer with externalIdentifier K0003
which has a Phone Extension with extension number 15
When I send /api/customers/K0002/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0003/targets/phone-extensions/15"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Phone Extension 15 does not belong to Customer K0002!"
  }]
}
Admin cannot create Group Service Members for missing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/15"
  }]
}
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 Group Service Members for another Customer
And there is a Group Service with service number 123 and there is a Phone Extension with extension number 15
and I am authenticated as Customer K0003
When I send /api/customers/K0002/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0002/targets/phone-extensions/15"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot create Group 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/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0003/targets/phone-extensions/15"
  }]
}
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 Group Service Member for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/group-services/123/members with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "phoneExtension",
    "href": "/api/customers/K0003/targets/phone-extensions/15"
  }]
}
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"
}