Api >

Service Portal REST API

GET returns requested Announcement
Given I am authenticated as customer K0002
and there is an MUSIC_ON_HOLD announcement with ID 15, name Welcome and file name announcement.wav
and duration 10 When I send /api/customers/K0002/announcements/15
Then I should receive HTTP/1.1 200 OK with following body:
{
  "href": "/api/customers/K0002/announcements/15",
  "links": [],
  "data": [{
    "name": "name",
    "value": "Welcome"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD"
  }, {
    "name": "duration",
    "value": 10
  }]
}
GET returns Announcement file when Accept is audio/x-wav
Given I am authenticated as Customer K0002
and there is with Id 15 and name announcement.wav
and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
When I send /api/customers/K0002/announcements/15 with header audio/x-wav
Then I should receive HTTP/1.1 200 OK with audio/x-wav and response body is equal to ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav content
and attachment; filename="announcement.wav"
GET returns 400 if Announcement is missing metadata
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 When I send /api/customers/K0002/announcements/15
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "title": "Announcement metadata not found",
  "detail": "Announcement with id 15 has missing details. Remove it and upload again.",
  "described_by": "http://api.nfon.net/probs/announcement-metadata-not-found"
}
GET returns 404 if Customer is missing
Given I am authenticated as Admin
and there is no Customer K0404
When I send /api/customers/K0404/announcements/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"
}
GET returns 404 if requested Announcement is missing
Given I am authenticated as Customer K0002
and there is no Announcement with Id 404
When I send /api/customers/K0002/announcements/404
Then I should receive HTTP/1.1 404 Not Found with following body:
{
  "title": "Announcement not found",
  "detail": "Announcement with id 404 has not been found",
  "described_by": "http://api.nfon.net/probs/announcement-not-found"
}
GET returns 403 if requested Announcement belongs to another Customer
Given I am authenticated as K0003
and there is an Announcement with Id 15
When I send /api/customers/K0002/announcements/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 get Announcement of Customer, that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/announcements/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 get Announcement of Customer, that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/announcements/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"
}