Api >

Service Portal REST API

Should create Announcement
Given I am authenticated as Customer K0002
And next Announcement ID will be 100 When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
Then I should receive HTTP/1.1 201 Created
with http://localhost:9998/api/customers/K0002/announcements/100 and body:
{
  "href": "/api/customers/K0002/announcements/100"
}

Then when I am authenticated as Customer K0002
When I send /api/customers/K0002/announcements/100
Then I should receive HTTP/1.1 200 OK with following body:
{
  "href": "/api/customers/K0002/announcements/100",
  "links": [],
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }, {
    "name": "duration",
    "value": 8
  }]
}

Then when I am authenticated as Customer K0002
When I send /api/customers/K0002/announcements/100 with header audio/x-wav
Then I should receive HTTP/1.1 200 OK with audio/x-wav
Announcement name must be unique
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
and name announcement.mp3
When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.mp3"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Announcement name must be unique",
    "path": "name",
    "value": "announcement.mp3"
  }]
}
Announcement file size must not exceed file size limit
Given I am authenticated as Customer K0002
When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/fileSizeExceeds.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "fileSizeExceeds.wav"
  }, {
    "name": "type",
    "value": "GENERAL_ANNOUNCEMENT"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
and body:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "Announcement file size exceeds the limit of 7340032 bytes (about 7 MB)",
    "path": "file",
    "value": 7954510
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create Announcement with empty name
Given I am authenticated as Customer K0002
And next Announcement ID will be 100 When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": null
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Announcement name is required",
    "path": "name",
    "value": null
  }]
}
Cannot create Announcement with invalid type
Given I am authenticated as Customer K0002
And next Announcement ID will be 100 When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "INVALID"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Unknown enum value. Allowed values: [MUSIC_ON_HOLD, MUSIC_ON_HOLD_QUEUE, MUSIC_ON_HOLD_SKILL, GENERAL_ANNOUNCEMENT]",
    "path": "type",
    "value": "INVALID"
  }]
}
Cannot create Announcement with empty type
Given I am authenticated as Customer K0002
And next Announcement ID will be 100 When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": null
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Announcement type is required",
    "path": "type",
    "value": null
  }]
}
Cannot create Announcement with MUSIC_ON_HOLD type if it already exists
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
and name announcement.mp3
and name MUSIC_ON_HOLD
When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Customer can only have one MUSIC_ON_HOLD announcement",
    "path": "type",
    "value": "MUSIC_ON_HOLD"
  }]
}
Cannot create Announcement with non-audio file
Given I am authenticated as Customer K0002
When I send /api/customers/K0002/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/not_audio.gif
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "not_audio.gif"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "File 'not_audio.gif' is not a WAV/MP3 file.",
    "path": "audiofile"
  }]
}
POST returns 404 if Customer is missing
Given I am authenticated as Admin
And next Announcement ID will be 100 When I send /api/customers/K0404/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
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"
}
POST returns 403 if Announcement belongs to another Customer
Given I am authenticated as Customer K0002
And next Announcement ID will be 100 When I send /api/customers/K0003/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
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"
}
System Integrator cannot create Announcement of Customer, that does not belong to him
Given I am authenticated as System Integrator S0002
And next Announcement ID will be 100 When I send /api/customers/K0003/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
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 Announcement of Customer, that does not belong to him
Given I am authenticated as Operator C0002
And next Announcement ID will be 100 When I send /api/customers/K0003/announcements
with following multipart body:
Part Name: audiofile Content Type: audio/x-wav
classpath:net/nfon/portal/api/customer/announcement/announcement.wav
Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement.wav"
  }, {
    "name": "type",
    "value": "MUSIC_ON_HOLD_SKILL"
  }]
}
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"
}