Phone API Reference - Extended - pbx.request
Desk Phone API features described in this section are deprecated and supported only on the following models: D40, d45, d50, d60, d62, d65, d70
pbx.request
Description
Sends an API request and (optionally) handles the response. This may require an authenticated Auth object.
For information regarding the Switchvox Extend API visit http://developers.digium.com/switchvox/.
 Â
Basic Example:Â
pbx.request(parameters); |
Parameters
Name | Required | Type | Default | Description |
---|---|---|---|---|
method | Yes | string | Â | Name of the API method to call. |
parameters | No | object | Â | Javascript Object containing key value pairs of values appriopriate to the API method. Default is empty object. |
onSuccess | No | function | Â | Function to execute if request returns with a success status. This function will be passed a hash with the format {'result' : queryResultObject, 'method' : 'apiMethod'}. Callback function to call when the request successfully completes. If nothing is passed, the default onSuccess callback writes a success message to the log. |
onError | No | function | Â | Callback function to call when there is an error making the request. If nothing is passed in, the default onError callback shows a screen that displays the error. |
loadingText | No | string | Â | Message to display during request execution. If none is provided, the loading screen will not be displayed. If you want to send the requeset to the PBX the phone is configured to as the extension the phone is configured as, then this parameters is not needed. If you want to send the request to another PBX or make it as another user, then you need to pass in an Auth object. |
auth | No | object | Â | An auth object that contains the account_id, username, password, and server address to authorize pbx requests. If you want to send the request to the PBX the phone is configured to as the extension the phone is configured as, then this parameter is not needed. If you want to send the request to another PBX or make it as another user, then you need to pass in an Auth object. |
Â
Examples
pbx.request to print extension info associated with the account
pbx.request({
    'method' : ' switchvox.users.getMyInfo',
    'loadingText' : 'Getting extension info',
    'onSuccess' : function (response) {
        util.debug(response.result.extension.number);
    }
    }); |
Â
pbx.request to retrieve a presence option list for specified account
 pbx.request({
        'method'       : 'switchvox.users.presence.options.getList',
        'parameters'   : {
            'account_id' : "1235"
        },
        'loadingText'  : app.t('STATUSLIST_LOADING'),
        'onSuccess'    : function (p) {
            util.debug("We got status options");
            util.debug(JSON.stringify(p.result.presence_options));
        }
    }); |
Â