Api >

Service Portal REST API

POST assigns inbound trunk number to group service
Given I am authenticated as Customer K0002
And there is a Group Service with service number 345
And there is an Inbound Trunk Number +48 (22) 1111-5
When I send /api/customers/K0002/targets/group-services/345/inbound-trunk-numbers with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0002/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
Then I should receive HTTP/1.1 201 Created
With header http://localhost:9998/api/customers/K0002/targets/group-services/345/inbound-trunk-numbers/0048.22.1111-5
And Inbound Trunk Number is assigned to Group Service
POST validates if extension is within trunk number range
Given I am authenticated as Customer K0002
And there is a Group Service with service number 345
And there is an Inbound Trunk Number +48 (22) 1111-200
When I send /api/customers/K0002/targets/group-services/345/inbound-trunk-numbers with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0002/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "404"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body
{
  "errors": [{
    "message": "Invalid trunk or extension number"
  }]
}
Cannot create inbound trunk number for missing Group Service
Given I am authenticated as Customer K0002
When I send /api/customers/K0002/targets/group-services/404/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0002/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
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"
}
Should not create Inbound Trunk Number with missing link to Trunk
Given I am authenticated as Customer K0002
And there is a Group Service with service number 5 When I send /api/customers/K0002/targets/group-services/5/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
Then I should get HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Value must be provided",
    "path": "trunk"
  }]
}
Customer cannot create Inbound Trunk Number with link to another Customer's Trunk
Given I am authenticated as Customer K0002
And there is a Group Service with service number 5 and there is an another customer with externalIdentifier K0003
which has an Inbound Trunk Number +48 (22) 1111-200
When I send /api/customers/K0002/targets/group-services/5/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0003/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
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 Inbound Trunk Number with link to another Customer's Trunk
Given I am authenticated as Admin
And there is a Group Service with service number 5 and there is an another customer with externalIdentifier K0003
which has an Inbound Trunk Number +48 (22) 1111-200
When I send /api/customers/K0002/targets/group-services/5/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0003/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Invalid trunk or extension number"
  }]
}
Should not create Inbound Trunk Number with not existing Trunk
Given I am authenticated as Customer K0002
And there is a Group Service with service number 5 When I send /api/customers/K0002/targets/group-services/5/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0002/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
Then I should get HTTP/1.1 404 Not Found with following body:
{
  "title": "Trunk not found",
  "detail": "Trunk with number 0048.22.1111.0-9 has not been found",
  "described_by": "http://api.nfon.net/probs/trunk-not-found"
}
Admin cannot create Inbound Trunk Numbers for missing Customer
Given I am authenticated as Admin
When I send /api/customers/K404/targets/group-services/345/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0404/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
Then I should get HTTP/1.1 404 Not Found
{
  "title": "Customer not found",
  "detail": "Customer with identifier K404 has not been found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
Customer cannot create Inbound Trunk Number for another Customer's Group Service
Given there is a Group Service with service number 345
and I am authenticated as K0003
When I send /api/customers/K0002/targets/group-services/345/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0002/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
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 Inbound Trunk Number 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/345/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0003/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
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 Inbound Trunk Number for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/targets/group-services/345/inbound-trunk-numbers with header application/json; charset=UTF-8
and with body
{
  "links": [{
    "rel": "trunk",
    "href": "/api/customers/K0003/trunks/0048.22.1111.0-9"
  }],
  "data": [{
    "name": "didExtension",
    "value": "5"
  }]
}
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"
}