/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Object used to request social information from the container. * This includes data for friends, profiles, app data, and activities. * * All apps that require access to people information should send a dataRequest * in order to receieve a dataResponse */ /** * @class *
* Used to request social information from the container. * This includes data for friends, profiles, app data, and activities. * All apps that require access to people information * should send a DataRequest. *
* ** Here's an example of creating, initializing, sending, and handling * the results of a data request: *
* *function requestMe() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(
opensocial.IdSpec.PersonId.VIEWER),
"viewer");
req.send(handleRequestMe);
};
function handleRequestMe(data) {
var viewer = data.get("viewer");
if (viewer.hadError()) {
//Handle error using viewer.getError()...
return;
}
//No error. Do something with viewer.getData()...
}
*
* See also:
*
* opensocial.newDataRequest()
*
opensocial.Person.Field
* specifying what profile data to fetch
* for each of the person objects. The server will always include
* ID, NAME, and THUMBNAIL_URL.
* This field may be used interchangeably with the string 'profileDetail'.
* @member opensocial.DataRequest.PeopleRequestFields
*/
PROFILE_DETAILS : 'profileDetail',
/**
* A sort order for the people objects; defaults to TOP_FRIENDS.
* Possible values are defined by
* SortOrder.
* This field may be used interchangeably with the string 'sortOrder'.
* @member opensocial.DataRequest.PeopleRequestFields
*/
SORT_ORDER : 'sortOrder',
/**
* How to filter the people objects; defaults to ALL.
* Possible values are defined by
* FilterType.
* This field may be used interchangeably with the string 'filter'.
* @member opensocial.DataRequest.PeopleRequestFields
*/
FILTER : 'filter',
/**
* Additional options to be passed into the filter,
* specified as a Map<String, Object>.
* This field may be used interchangeably with the string 'filterOptions'.
* @member opensocial.DataRequest.PeopleRequestFields
*/
FILTER_OPTIONS: 'filterOptions',
/**
* When paginating, the index of the first item to fetch;
* specified as a number.
* This field may be used interchangeably with the string 'first'.
* @member opensocial.DataRequest.PeopleRequestFields
*/
FIRST : 'first',
/**
* The maximum number of items to fetch,
* specified as a number; defaults to 20. If set to a larger
* number, a container may honor the request, or may limit the number to a
* container-specified limit of at least 20.
* This field may be used interchangeably with the string 'max'.
* @member opensocial.DataRequest.PeopleRequestFields
*/
MAX : 'max'
};
/**
* Creates an item to request a profile for the specified person ID.
* When processed, returns a
* Person object.
*
* @param {String} id The ID of the person to fetch; can be the standard
* person ID
* of VIEWER or OWNER
* @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>}
* opt_params
* Additional
* parameters
* to pass to the request; this request supports PROFILE_DETAILS
* @return {Object} A request object
*/
opensocial.DataRequest.prototype.newFetchPersonRequest = function(id,
opt_params) {};
/**
* Creates an item to request friends from the server.
* When processed, returns a Collection
* <Person> object.
*
* @param {opensocial.IdSpec} idSpec An IdSpec used to specify
* which people to fetch. See also IdSpec.
* @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>}
* opt_params
* Additional
* params
* to pass to the request
* @return {Object} A request object
*/
opensocial.DataRequest.prototype.newFetchPeopleRequest = function(idSpec,
opt_params) {};
/**
* @static
* @class
* @name opensocial.DataRequest.DataRequestFields
*/
opensocial.DataRequest.DataRequestFields = {
/**
* How to escape person data returned from the server; defaults to HTML_ESCAPE.
* Possible values are defined by
* EscapeType.
* This field may be used interchangeably with the string 'escapeType'.
* @member opensocial.DataRequest.DataRequestFields
*/
ESCAPE_TYPE : 'escapeType'
};
/**
* Creates an item to request app data for the given people.
* When processed, returns a Map<
* PersonId,
* Map<String,
* Object>> object. All of the data values returned will be valid json.
*
* @param {opensocial.IdSpec} idSpec An IdSpec used to specify
* which people to fetch. See also IdSpec.
* @param {Array.<String> | String} keys The keys you want data for; this
* can be an array of key names, a single key name, or "*" to mean
* "all keys"
* @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
* opt_params Additional
* params
* to pass to the request
* @return {Object} A request object
*/
opensocial.DataRequest.prototype.newFetchPersonAppDataRequest = function(idSpec,
keys, opt_params) {};
/**
* Creates an item to request an update of an app field for the given person.
* When processed, does not return any data.
*
* @param {String} id The ID of the person to update; only the
* special VIEWER ID is currently allowed.
* @param {String} key The name of the key. This may only contain alphanumeric
* (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).
* @param {Object} value The value, must be valid json
* @return {Object} A request object
*/
opensocial.DataRequest.prototype.newUpdatePersonAppDataRequest = function(id,
key, value) {};
/**
* Deletes the given keys from the datastore for the given person.
* When processed, does not return any data.
*
* @param {String} id The ID of the person to update; only the
* special VIEWER ID is currently allowed.
* @param {Array.<String> | String} keys The keys you want to delete from
* the datastore; this can be an array of key names, a single key name,
* or "*" to mean "all keys"
* @return {Object} A request object
*/
opensocial.DataRequest.prototype.newRemovePersonAppDataRequest = function(id,
keys) {};
/**
* Creates an item to request an activity stream from the server.
*
* * When processed, returns a Collection<Activity>. *
* * @param {opensocial.IdSpec} idSpec An IdSpec used to specify * which people to fetch. See also IdSpec. * @param {Map.<opensocial.DataRequest.ActivityRequestFields, Object>} * opt_params * Additional parameters * to pass to the request; not currently used * @return {Object} A request object */ opensocial.DataRequest.prototype.newFetchActivitiesRequest = function(idSpec, opt_params) {};