Force.com-JavaScript-REST-Toolkit icon indicating copy to clipboard operation
Force.com-JavaScript-REST-Toolkit copied to clipboard

Add Chatter REST API calls

Open tloebach opened this issue 12 years ago • 0 comments

Here is code for forcetk.js that adds in the ability to access Chatter.

/*
 * Retrieves field values for a Chatter record of the given type.
 * @param objtype object type; e.g. "comments"
 * @param id the record's object ID
 * @param [fields=null] optional comma-separated list of fields for which
 *               to return values; e.g. Name,Industry,TickerSymbol
 * @param callback function to which response will be passed
 * @param [error=null] function to which jqXHR will be passed in case of error
 */

forcetk.Client.prototype.chatter = function(objtype, id, fieldlist, callback, error) {
if (!arguments[4]) {
    error = callback;
    callback = fieldlist;
    fieldlist = null;
}
var fields = fieldlist ? '?fields=' + fieldlist : '';
this.ajax('/' + this.apiVersion + '/chatter/' + objtype + '/' + id
          + fields, callback, error);
}

tloebach avatar Nov 26 '12 18:11 tloebach