REST Base

Class finesse.restservices.RestBase

Represents the JavaScript REST object and it exposes methods to operate on the object against the server. This object is extended to individual JavaScript REST objects (such as Dialog, User, and so on) and is not be used directly.

Example
Code Snippet
Copyvar NotReadyReasonCode = RestBase.extend( /** @lends finesse.restservices.NotReadyReasonCode.prototype */ {

            /**
             * @class
             * A ReasonCode object for NOT_READY state.
             *
             * @augments finesse.restservices.RestBase
             * @see finesse.restservices.User.States#NOT_READY
             * @constructs
             */
            _fakeConstuctor: function() {
                /* This is here to hide the real init constructor from the public docs */
            },

For additional parameters and methods, see RestBase Common Parameters.

Field Details

Name

Description

ajaxRequestTimeout

Duration in milliseconds that the OpenAjax request remains opened.

restResponseStatus

Number of the REST response status that is returned.

Methods

addHandler(notifierType, callback, scope)

Add a handler for the specific RestBase object. The callback function is invoked if the notifierType is triggered.

Example

Code Snippet
Copy// Handler for additions to the Dialogs collection object.  
// When Dialog (a RestBase object) is created, add a change handler.
_handleDialogAdd = function(dialog) {
    dialog.addHandler('change', _handleDialogChange);
}

Parameters

Name

Type

Description

Required

notifierType

String

The type of notifier to add to the load, change, add, delete, and error.

Yes

callback

Function

An asynchronous callback function that is invoked when the type is notified.

Yes

scope

Object

The object on which the handler is invoked.

Optional

getData()

Retrieves the data for an object.

Returns

{Object} The object with the retrieved data.

getId()

Retrieves the unique identifier of the RestBase.

Returns

{String} Unique identifier of the RestBase.

getProperty(obj, property)

Retrieves the property from the object.

Parameters

Name

Type

Description

Required

obj

Object

The object to retrieve the property from.

Yes

property

String

The property is the key of the value that will be returned.

Yes

Returns

{Object} The value of the property that was requested.

hasProperty(obj, property)

Determines whether the object has a property.

Parameters

Name

Type

Description

Required

obj

Object

The object to check if the property exists.

Yes

property

String

The property is the key of the value that will be returned.

Yes

Returns

{Boolean} True if the object contains the property, else false.

isLoaded()

Loads the utility method for operations that require complete instantiation.

Throws

{Error} If this object is not fully instantiated.

Returns

{finesse.restservices.RestBase} The RestBase object reference. Makes the isLoaded function available to all the classes which are extending RestBase class. For example, in Dialogs, this.isloaded() can be called Dialogs.js which is the child class of RestBase.

refresh(retries)

Updates the RestBase object with the latest data by performing an asynchronous GET. The updated object will be returned through the onChange handler, so make sure it is registered.

Parameters

Name

Type

Description

Required

retries

Integer

The number of retry attempts to update the RestBase object.

Yes

Returns

{Object} The end-call function that signifies the callback handler to not process the response of the asynchronous request.

removeHandler(notifierType, callback)

Removes previously added handler for the specified notifierType.

Parameters

Name

Type

Description

Required

notifierType

String

The type of notifier to remove the load, change, add, delete, and error.

Yes

callback

Function

The callback to be removed.

Yes