API Docs for:
Show:

plugin_rest_user Class

Module: plugins_rest
Parent Module: com_user_rest

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

GET requests

  1. user/presence
  2. user/presencelist
  3. user/presencelist_onbusy
  4. user/presencelist_onunavailable
  5. user/presence_onbusy
  6. user/presence_onunavailable
  7. user/me
  8. user/endpoints/all
  9. user/paramurl

user/presence

Returns the user presence status.

Example JSON response:

{ "status": "online" }

user/presencelist

Returns the list of the possible user presence status.

Example JSON response:

["online", "dnd", "voicemail", "cellphone", "callforward"]

user/presencelist_onbusy

Returns the list of the possible conditional user presence on busy status.

Example JSON response:

["callforward", "voicemail", "online", "cellphone"]

user/presencelist_onunavailable

Returns the list of the possible conditional user presence on unavailable status.

Example JSON response:

["callforward", "voicemail", "online", "cellphone"]

user/presence

Returns the user presence status.

Example JSON response:

{ "status": "online" }
{ "status": "voicemail" }
{ "status": "cellphone" }
{ "status": "callforward", "to": "12345" }

user/presence_onbusy

Returns the conditional user presence status on busy.

Example JSON response:

{ "status": "online" }
{ "status": "cellphone" }
{ "status": "voicemail" }
{ "status": "callforward", "to": "12345" }

user/presence_onunavailable

Returns the conditional user presence status on unavailable.

Example JSON response:

{ "status": "online" }
{ "status": "cellphone" }
{ "status": "voicemail" }
{ "status": "callforward", "to": "12345" }

user/me

Returns the information about the user.

Example JSON response:

 {
   "presence": "online",
   "name": "user admin",
   "username": "user",
   "endpoints": {
     "email": [
       {
         "id": "user@nethesis.it"
       }
     ],
     "jabber": [
       {
         "id": "user@nethesis.it",
         "server": "https://my.server.it/http-bind"
       }
     ],
     "extension": [
       {
         "id": "91301",
         "description": "Yealink SIP-T22P 7.73.0.50",
         "type": "physical",
         "web_user": "admin",
         "web_password": "admin",
         "actions": {
           "answer": true,
           "dtmf": true,
           "hold": true
         }
       },
       {
         "id": "92301",
         "description": "janus",
         "type": "webrtc",
         "secret": "password",
         "actions": {
           "answer": true,
           "dtmf": true,
           "hold": true
         }
       },
       {
         "id": "92304",
         "description": "janus",
         "type": "webrtc_mobile",
         "secret": "password",
         "actions": {
           "answer": true,
           "dtmf": true,
           "hold": true
         }
       }
     ],
     "cellphone": [
       {
         "id": "1234567890"
       }
     ],
     "voicemail": [
       {
         "id": "301"
       }
     ],
     "mainextension": [
       {
         "id": "301",
         "description": "Yealink SIP-T22P 7.73.0.50"
       }
     ]
   },
   "profile": {
     "id": "3",
     "name": "Advanced",
     "macro_permissions": {
       "settings": {
         "value": true,
         "permissions": {
           "call_waiting": {
             "id": "1",
             "name": "call_waiting",
             "value": true
           },
           ...
         }
       },
       ...
     }
   },
   "default_device": {
     "id": "200",
     "type": "webrtc",
     "secret": "12345",
     "username": "200",
     "description": "Yealink"
   },
   "settings": {
     "prop1": "value1",
     "prop2": {
       "sub-key2": "sub-value2"
     },
     "prop3": [
       "sub-key3",
       {
         "sub-key3a": "sub-value3a"
       }
     ],
     "default_extension": "200",
     ...
   }
 }

user/all_avatars

Returns all user settings.

Example JSON response:

{
 "giovanni": "data:image/jpeg;base64,/9j/QCF69485Hjj=//gADKv/iC/hJQ0Nf..",
 "alessandro": "data:image/jpeg;base64,/9j/QCF69485Hjj=//5AFKE/iC/hJQ0Nf.."
}

user/endpoints/all

Returns the information about all users endpoints.

Example JSON response:

 {
   "alessandro": {
       "name": "Alessandro Polidori",
       "presence": "online",
       "username": "alessandro",
       "endpoints": {
           "email": [],
           "extension": [
               {
                   "id": "223",
                   "type": "physical",
                   "description": "Yealink SIP-T22P 7.73.0.50"
               },
               {
                   "id": "91223",
                   "type": "webrtc",
                   "secret": "9793a942680ac41f29296d1cae8bdfb6",
                   "username": "91223",
                   "description": "Janus WebRTC Gateway SIP Plugin 0.0.6"
               }
           ],
           "cellphone": [
               {
                   "id": "3405512345"
               }
           ],
           "voicemail": [
               {
                   "id": "223"
               }
           ],
           "mainextension": [
               {
                   "id": "223",
                   "description": "Yealink SIP-T22P 7.73.0.50"
               }
           ]
       }
   },
   ...
 }

user/paramurl

Returns the parameterized URL allowed for the user profile.

Example JSON response:

 {
   "id": 84, "profile_id": 3, "url": "https://mycrm.it/script.php?caller=$CALLER_NAME..."}
 }

POST requests

  1. user/presence
  2. user/presence_onbusy
  3. user/presence_onunavailable
  4. user/settings
  5. user/default_device
  6. user/mobile

user/presence

Set the user presence status. The request must contain the following parameters:

  • status: valid status obtained by GET user/presencelist
  • [to]: valid destination number to be specified with "callforward" status

Example JSON request parameters:

{ "status": "online" }
{ "status": "dnd" }
{ "status": "voicemail" }
{ "status": "cellphone" }
{ "status": "callforward", "to": "0123456789" }

user/presence_onbusy

Set the conditional user presence on busy status. The request must contain the following parameters:

  • status: valid status obtained by GET user/presencelist_onbusy
  • [to]: valid destination number to be specified with "callforward" status

Example JSON request parameters:

{ "status": "online" }
{ "status": "voicemail" }
{ "status": "cellphone" }
{ "status": "callforward", "to": "0123456789" }

user/presence_onunavailable

Set the conditional user presence on unavailable status. The request must contain the following parameters:

  • status: valid status obtained by GET user/presencelist_onunavailable
  • [to]: valid destination number to be specified with "callforward" status

Example JSON request parameters:

{ "status": "online" }
{ "status": "voicemail" }
{ "status": "cellphone" }
{ "status": "callforward", "to": "0123456789" }

user/settings

Save the user settings. The request must contain the following parameters:

  • data: a valid JSON object. Keys must to be strings of maximum length of 50 characters.

Example JSON request parameters:

{ "key1": "value1", "key": { "sub-key1": "sub-value1" } } }

user/default_device

Set the user default device to be used for call operations. The request must contain the following parameters:

  • id: the extension identifier

Example JSON request parameters:

{ "id": "214" }

user/mobile

Associate a mobile phone number to the user. The request must contain the following parameters:

  • number: the mobile phone number

Example JSON request parameters:

{ "number": "3401234567" }

DELETE requests

  1. user/settings
  2. user/setting/:prop

user/settings

Delete all the user settings.

user/setting/:prop

Delete the setting property of the user. The request must contain the following parameters:

  • prop: the setting property to be deleted. It can be a key set with "user/settings" POST api

Example JSON request parameters:

{ "prop": "avatar" }

Methods

all_avatars

(
  • req
  • res
  • next
)

Get all users settings by the following REST API:

all_avatars

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

default_device

(
  • req
  • res
  • next
)

Set the default extension for the user by the following REST API:

default_device

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

endpoints

(
  • req
  • res
  • next
)

Get all endpoints by the following REST API:

endpoints

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

me

(
  • req
  • res
  • next
)

Get the information about the user by the following REST API:

me

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

mobile

(
  • req
  • res
  • next
)

Associate a mobile phone number to the user with the following REST API:

POST mobile

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

paramurl

(
  • req
  • res
  • next
)

Get the parameterized URL fot he user profile by the following REST API:

paramurl

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

presence

(
  • req
  • res
  • next
)

Manages GET and POST requests to get/set the status presence of the user with the following REST API:

GET  presence
POST presence

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

presence_onbusy

(
  • req
  • res
  • next
)

Manages GET and POST requests to get/set the conditional status presence on busy of the user with the following REST API:

GET presence_onbusy
POST presence_onbusy

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

presence_onunavailable

(
  • req
  • res
  • next
)

Manages GET and POST requests to get/set the conditional status presence on unavailable of the user with the following REST API:

GET presence_onunavailable
POST presence_onunavailable

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

presenceGet

(
  • req
  • res
  • next
)

Get the user presence status.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

presencelist

(
  • req
  • res
  • next
)

Get the list of possible presence status by the following REST API:

presencelist

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

presencelist_onbusy

(
  • req
  • res
  • next
)

Get the list of possible conditional presence on busy status by the following REST API:

presencelist_onbusy

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

presencelist_onunavailable

(
  • req
  • res
  • next
)

Get the list of possible conditional presence on unavailable status by the following REST API:

presencelist_onunavailable

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

presenceOnBusyGet

(
  • req
  • res
  • next
)

Get the conditional user presence status on busy.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

presenceOnBusySet

(
  • req
  • res
  • next
)

Set the conditional user presence status on busy.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

presenceOnUnavailableGet

(
  • req
  • res
  • next
)

Get the conditional user presence status on unavailable.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

presenceOnUnavailableSet

(
  • req
  • res
  • next
)

Set the conditional user presence status on unavailable.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

presenceSet

(
  • req
  • res
  • next
)

Set the user presence status.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

setCompAstProxy

(
  • comp
)

Set asterisk proxy architect component.

Parameters:

  • comp Object

    The asterisk proxy architect component.

setCompAuthorization

(
  • ca
)

Set authorization architect component.

Parameters:

  • ca Object

    The authorization architect component.

setCompConfigManager

(
  • comp
)

Set configuration manager architect component.

Parameters:

  • comp Object

    The configuration manager architect component.

setCompUser

(
  • comp
)

Set user architect component used for user functions.

Parameters:

  • comp Object

    The user 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. It must have at least three methods: info, warn and error as console object.

settings

(
  • req
  • res
  • next
)

Delete a single user setting by the following REST API:

DELETE setting

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

settings

(
  • req
  • res
  • next
)

Save/Delete the user settings by the following REST API:

POST settings
DELETE settings

Parameters:

  • req Object

    The client request

  • res Object

    The client response

  • next Function

    Function to run the next handler in the chain

settingsDelete

(
  • req
  • res
  • next
)

Delete all the user settings.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

settingsPost

(
  • req
  • res
  • next
)

Save the user settings.

Parameters:

  • req Object

    The request object

  • res Object

    The response object

  • next Object

Properties

compAstProxy

Object private

The asterisk proxy architect component.

compAuthorization

Object private

The architect component to be used for authorization.

compConfigManager

Object private

The configuration manager architect component.

compUser

Object private

The architect component to be used for user functions.

compUtil

Object private

The utility architect component.

del

Array

REST API to be requested using HTTP DELETE request.

Sub-properties:

  • settings String

    Delete all user settings

  • setting/:prop String

    Delete a single user setting

get

Array

REST API to be requested using HTTP GET request.

Sub-properties:

  • me String

    To get the user information

  • paramurl String

    To get the parameterized URL for the user profile

  • presence String

    To get the user presence status

  • presence_onbusy String

    To get the conditional user presence status on busy

  • presence_onunavailable String

    To get the conditional user presence status on unavailable

  • presencelist String

    To get the list of possible presence status

  • presencelist_onbusy String

    To get the list of possible conditional presence on busy status

  • presencelist_onunavailable String

    To get the list of possible conditional presence on unavailable status

  • all_avatars String

    To get the all user settings

IDLOG

String private final

The module identifier used by the logger.

Default: [plugins_rest/user]

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:

  • presence String

    Set a presence status for the user

  • settings String

    Save the user settings

  • default_device String

    Set a default extension for the user

  • presence_onbusy String

    Set a conditional presence status on busy for the user

  • presence_onunavailable String

    Set a conditional presence status on unavailable for the user

  • mobile String

    Associate a mobile phone number to the user