API Docs for:
Show:

plugin_rest_offhour Class

Module: plugins_rest
Parent Module: com_offhour_rest

REST plugin that provides offhour functions through the following REST API:

GET requests

  1. offhour/list
  2. offhour/list_announcement
  3. offhour/listen_announcement/:id
  4. offhour/download_announcement/:id

offhour/list

If the user has the admin permission it returns all inbound routes. If the user has the advanced permission it returns generic inbound routes and these owned by the user. If the user has the basic permission it returns only inbound routes owned by the user.

Example JSON response:

{
  "0721405516/0123456798": {
             "calledIdNum": "0721405516",
             "callerIdNum": "0123456798",
             "destination": "from-did-direct,201,1",
             "description": "alessandro polidori",
             "offhour": {
               "calledIdNum": "0721405516",
               "callerIdNum": "0123456798",
               "action": "audiomsg_voicemail",
               "enabled": "period",
               "period": {
                 "datebegin": "01/12/2017",
                 "dateend": "18/12/2017",
                 "timebegin": "12:52:51",
                 "timeend": "18:00:00"
               },
               "audiomsg": {
                 "announcement_id": "1",
                 "description": "vacanze",
                 "privacy": "public",
                 "username": "alessandro"
               },
               "voicemail": {
                 "voicemail_id": "200"
               }
             }
           },
           ...
         }

offhour/list_announcement

Returns the list of all public and user private audio file for announcements.

Example JSON response:

[
    {
        "id": 1,
        "username": "alessandro",
        "description": "lunch",
        "privacy": "private",
        "date_creation": "10/10/2017",
        "time_creation": "15:05:51"
    }
]

offhour/listen_announcement/:id

Listen the specified audio announcement. The id is the announcement indentifier in the database (id field of the nethcti3.offhour_files_ database table). The user with admin permission can listen all announcements, while the user with advanced and basic permissions can listen only the owned file and these with public visibility.


offhour/download_announcement/:id

The user can download the announcement message of the user. The id must be the identifier of the announcement in the database. It returns the filename that can be downloaded getting it from /webrest/static/.

POST requests

  1. offhour/enable_announcement
  2. offhour/modify_announcement
  3. offhour/delete_announcement
  4. offhour/record_announcement
  5. offhour/upload_announcement
  6. offhour/set_offhour

offhour/enable_announcement

Enable the specified audio file for announcement. It is to be used after "offhour/record_announcement" rest api invocation. The request must contain the following parameters:

  • privacy: ("public" | "private" ) the visibility of the announcement
  • description: the announcement description
  • tempFilename: the temporary file name given by the server when receives the upload or when the offhour/record_announcement has been used

Example JSON request parameters:

{ "privacy": "public", "description": "holidays time", "tempFilename": "upload_456b484edba171871e44b9d64b3bad3d.wav" }

offhour/modify_announcement

Modify data about the specified audio file for announcement. The request must contain at least one the following optional parameters:

  • id: the announcement identifier
  • [description]: the description of the announcement
  • [privacy]: ("public" | "private") the visibility of the announcement

Example JSON request parameters:

{ "id": "2", "privacy": "public" }

offhour/delete_announcement

Delete the specified audio file for announcement. The request must contain the following parameters:

  • id: the announcement identifier

Example JSON request parameters:

{ "id": "2" }

offhour/record_announcement

Record new audio file for announcement. It returns a filename that must be enabled invoking "offhour/enable_announcement" rest api.


offhour/upload_announcement

Upload an audio file as announcement to be used. The request must contain the following parameters:

  • privacy: ("public" | "private" ) the visibility of the announcement
  • description: the announcement description
  • audio_content: the audio file content base64 encoded. Supported formats are: mp3, wav

Example JSON request parameters:

{ "privacy": "public", "description": "pause", "audio_content": "data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAA..." }

offhour/set_offhour

Set the offhour service. It provides the functions to set offhour announcement, announcement + voicemail or redirect. The request must contain the following parameters:

  • calledIdNum: called number of the incoming route
  • callerIdNum: caller number of the incoming route
  • enabled: ("always" | "never" | "period") disable, enable always or enable for a period the offhour for the inbound route. If "period" is used it is necessary to specify "start_date", "start_time", "end_date" and "end_time"
  • [start_date]: used with "enabled=period" YYYYMMDD format
  • [start_time]: used with "enabled=period" HHmmss format
  • [end_date]: used with "enabled=period" YYYYMMDD format
  • [end_time]: used with "enabled=period" HHmmss format
  • [action]: ("audiomsg" | "audiomsg_voicemail" | "redirect") the type of the offhour
  • [announcement_id]: the identifier of the audo file announcement. It is required by action "audiomsg"
  • [voicemail_id]: the identifier of the voicemail extension. It is required by action "audiomsg_voicemail"
  • [redirect_to]: the redirection destination number. It is required by action "redirect"

Example JSON request parameters:

{ "action": "audiomsg_voicemail", "announcement_id": "2", "voicemail_id": "202" }

Methods

delete_announcement

(
  • req
  • res
  • next
)

Delete the audio file for announcement with the following REST API:

delete_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

download_announcement

(
  • req
  • res
  • next
)

The user download the audio file of the specified announcement with the following REST API:

download_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

downloadAnnouncement

(
  • id
  • username
  • res
)
private

Download audio announcement. It return the filename to be served by the static component.

Parameters:

  • id String

    The identifier of the call

  • username String

    The name of the user

  • res Object

    The client response

enable_announcement

(
  • req
  • res
  • next
)

Enable the uploaded audio file for announcement with the following REST API:

enable_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

list

(
  • req
  • res
  • next
)

If the user has the admin permission it returns all inbound routes. If the user has the advanced permission it returns generic inbound routes and these owned by the user. If the user has the basic permission it returns only inbound routes owned by the user.

list

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

list_announcement

(
  • req
  • res
  • next
)

Gets the list of all public and user private audio file for announcements with the following REST API:

list_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

listen_announcement

(
  • req
  • res
  • next
)

The user listen the audio file of the specified announcement with the following REST API:

listen_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

listenAnnouncement

(
  • id
  • username
  • res
)
private

Listen announcement using offhour component. This returns the content of the audio file using base64 enconding. So the data is sent to the client.

Parameters:

  • id String

    The identifier of the announcement

  • username String

    The name of the user

  • res Object

    The client response

modify_announcement

(
  • req
  • res
  • next
)

Modify some data about the audio file for announcement with the following REST API:

modify_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

record_announcement

(
  • req
  • res
  • next
)

Record new audio file for announcement with the following REST API:

record_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

set_offhour

(
  • req
  • res
  • next
)

Set the offhour for the inbound route. It provides the functions to set offhour announcement, announcement + voicemail or redirect and set validity "always", "period" or "never" with the following REST API:

set_offhour

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

setCompAuthorization

(
  • comp
)
static

Sets the authorization architect component.

Parameters:

  • comp Object

    The architect authorization component

setCompOffhour

(
  • comp
)

Set offhour architect component used by offhour functions.

Parameters:

  • comp Object

    The offhour architect component.

setCompStatic

(
  • comp
)

Set static http architecht component used by history functions.

Parameters:

  • comp Object

    The http static architect component.

setCompUtil

(
  • comp
)

Sets the utility architect component.

Parameters:

  • comp Object

    The utility architect component.

setLogger

(
  • log
)
static

Set the logger to be used.

Parameters:

  • log Object

    The logger object.

setOffhour

(
  • params
  • username
  • res
  • cb
)
private

Listen announcement using offhour component. This returns the content of the audio file using base64 enconding. So the data is sent to the client.

Parameters:

  • params Object

    The parameters passed by the client

  • username String

    The name of the user

  • res Object

    The response

  • cb Function

    The callback function

setOffhourOfAdvancedUser

(
  • username
  • req
  • res
  • cb
)
private

Set the offhour for the inbound route. The user has the advanced permission. It checks all the required permissions.

Parameters:

  • username String

    The name of the user

  • req Object

    The request

  • res Object

    The response

  • cb Function

    The callback function

setOffhourOfBasicUser

(
  • username
  • req
  • res
  • cb
)
private

Set the offhour for the inbound route. The user has the basic permission. It checks all the required permissions.

Parameters:

  • username String

    The name of the user

  • req Object

    The request

  • res Object

    The response

  • cb Function

    The callback function

upload_announcement

(
  • req
  • res
  • next
)

Upload the audio file for announcement with the following REST API:

upload_announcement

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

Properties

compAuthorization

Object private

The architect component to be used for authorization.

compOffhour

Object private

The offhour architect component used for offhour functions.

compStaticHttp

Object private

The http static module.

compUtil

Object private

The utility architect component.

get

Array

REST API to be requested using HTTP GET request.

Sub-properties:

  • list String

    To get the list of all the inbound routes base on user permission

  • list_announcement String

    To get the list of all public and user private audio file for announcements

  • listen_announcement/:id String

    To listen the specified audio file of announcement

  • download_announcement/:id String

    To download the specified audio file of announcement

IDLOG

String private final

The module identifier used by the logger.

Default: [plugins_rest/offhour]

logger

Object private

The logger. It must have at least three methods: info, warn and error.

Default: console

post

Array

REST API to be requested using HTTP POST request.

Sub-properties:

  • set_offhour String

    To Set the offhour service behaviour

  • modify_announcement String

    To modify some data about the audio file for announcement

  • delete_announcement String

    To delete the audio file for announcement

  • record_announcement String

    To record new audio file for announcement

  • enable_announcement String

    To enable the uploaded audio file for announcement

  • upload_announcement String

    To upload the audio file for announcement