build/tincan.js
function (cfg) {
            this.log("retrieveStateIds");
            var requestParams = {},
                requestCfg,
                requestHeaders,
                requestResult,
                callbackWrapper;

            cfg = cfg || {};
            requestHeaders = cfg.requestHeaders || {};

            requestParams.activityId = cfg.activity.id;
            if (this.version === "0.9") {
                requestParams.actor = JSON.stringify(cfg.agent.asVersion(this.version));
            }
            else {
                requestParams.agent = JSON.stringify(cfg.agent.asVersion(this.version));
            }
            if ((typeof cfg.registration !== "undefined") && (cfg.registration !== null)) {
                if (this.version === "0.9") {
                    requestParams.registrationId = cfg.registration;
                }
                else {
                    requestParams.registration = cfg.registration;
                }
            }

            requestCfg = {
                url: "activities/state",
                method: "GET",
                params: requestParams,
                headers: requestHeaders,
                ignore404: true
            };
            if (typeof cfg.callback !== "undefined") {
                callbackWrapper = function (err, xhr) {
                    var result = xhr;

                    if (err !== null) {
                        cfg.callback(err, result);
                        return;
                    }

                    if (xhr.status === 404) {
                        result = [];
                    }
                    else {
                        try {
                            result = JSON.parse(xhr.responseText);
                        }
                        catch (ex) {
                            err = "Response JSON parse error: " + ex;
                        }
                    }

                    cfg.callback(err, result);
                };
                requestCfg.callback = callbackWrapper;
            }
            if (typeof cfg.since !== "undefined") {
                requestCfg.params.since = cfg.since;
            }

            requestResult = this.sendRequest(requestCfg);
            if (! callbackWrapper) {
                requestResult.profileIds = null;
                if (requestResult.err !== null) {
                    return requestResult;
                }

                if (requestResult.xhr.status === 404) {
                    requestResult.profileIds = [];
                }
                else {
                    try {
                        requestResult.profileIds = JSON.parse(requestResult.xhr.responseText);
                    }
                    catch (ex) {
                        requestResult.err = "retrieveStateIds - JSON parse error: " + ex;
                    }
                }
            }
            return requestResult;
        }
function (cfg) {
            this.log("retrieveStateIds");
            var requestParams = {},
                requestCfg,
                requestHeaders,
                requestResult,
                callbackWrapper;

            cfg = cfg || {};
            requestHeaders = cfg.requestHeaders || {};

            requestParams.activityId = cfg.activity.id;
            if (this.version === "0.9") {
                requestParams.actor = JSON.stringify(cfg.agent.asVersion(this.version));
            }
            else {
                requestParams.agent = JSON.stringify(cfg.agent.asVersion(this.version));
            }
            if ((typeof cfg.registration !== "undefined") && (cfg.registration !== null)) {
                if (this.version === "0.9") {
                    requestParams.registrationId = cfg.registration;
                }
                else {
                    requestParams.registration = cfg.registration;
                }
            }

            requestCfg = {
                url: "activities/state",
                method: "GET",
                params: requestParams,
                headers: requestHeaders,
                ignore404: true
            };
            if (typeof cfg.callback !== "undefined") {
                callbackWrapper = function (err, xhr) {
                    var result = xhr;

                    if (err !== null) {
                        cfg.callback(err, result);
                        return;
                    }

                    if (xhr.status === 404) {
                        result = [];
                    }
                    else {
                        try {
                            result = JSON.parse(xhr.responseText);
                        }
                        catch (ex) {
                            err = "Response JSON parse error: " + ex;
                        }
                    }

                    cfg.callback(err, result);
                };
                requestCfg.callback = callbackWrapper;
            }
            if (typeof cfg.since !== "undefined") {
                requestCfg.params.since = cfg.since;
            }

            requestResult = this.sendRequest(requestCfg);
            if (! callbackWrapper) {
                requestResult.profileIds = null;
                if (requestResult.err !== null) {
                    return requestResult;
                }

                if (requestResult.xhr.status === 404) {
                    requestResult.profileIds = [];
                }
                else {
                    try {
                        requestResult.profileIds = JSON.parse(requestResult.xhr.responseText);
                    }
                    catch (ex) {
                        requestResult.err = "retrieveStateIds - JSON parse error: " + ex;
                    }
                }
            }
            return requestResult;
        }
function ( cfg ) { this . log ( "retrieveStateIds" ) ; var requestParams = { } , requestCfg , requestHeaders , requestResult , callbackWrapper ; cfg = cfg || { } ; requestHeaders = cfg . requestHeaders || { } ; requestParams . activityId = cfg . activity . id ; if ( this . version === "0.9" ) { requestParams . actor = JSON . stringify ( cfg . agent . asVersion ( this . version ) ) ; } else { requestParams . agent = JSON . stringify ( cfg . agent . asVersion ( this . version ) ) ; } if ( ( typeof cfg . registration !== "undefined" ) && ( cfg . registration !== null ) ) { if ( this . version === "0.9" ) { requestParams . registrationId = cfg . registration ; } else { requestParams . registration = cfg . registration ; } } requestCfg = { url : "activities/state" , method : "GET" , params : requestParams , headers : requestHeaders , ignore404 : true } ; if ( typeof cfg . callback !== "undefined" ) { callbackWrapper = function ( err , xhr ) { var result = xhr ; if ( err !== null ) { cfg . callback ( err , result ) ; return ; } if ( xhr . status === 404 ) { result = [ ] ; } else { try { result = JSON . parse ( xhr . responseText ) ; } catch ( ex ) { err = "Response JSON parse error: " + ex ; } } cfg . callback ( err , result ) ; } ; requestCfg . callback = callbackWrapper ; } if ( typeof cfg . since !== "undefined" ) { requestCfg . params . since = cfg . since ; } requestResult = this . sendRequest ( requestCfg ) ; if ( ! callbackWrapper ) { requestResult . profileIds = null ; if ( requestResult . err !== null ) { return requestResult ; } if ( requestResult . xhr . status === 404 ) { requestResult . profileIds = [ ] ; } else { try { requestResult . profileIds = JSON . parse ( requestResult . xhr . responseText ) ; } catch ( ex ) { requestResult . err = "retrieveStateIds - JSON parse error: " + ex ; } } } return requestResult ; }
Retrieve the list of IDs for a state, when used from a browser sends to the endpoint using the RESTful interface.

@method retrieveStateIds
@param {Object} cfg Configuration options
@param {TinCan.Activity} cfg.activity Activity in document identifier
@param {TinCan.Agent} cfg.agent Agent in document identifier
@param {String} [cfg.registration] Registration
@param {Function} [cfg.callback] Callback to execute on completion
@param {String} [cfg.since] Match activity profiles saved since given timestamp
@param {Object} [cfg.requestHeaders] Optional object containing additional headers to add to request
@return {Object} requestResult Request result
Retrieve the list of IDs for a state when used from a browser sends to the endpoint using the RESTful interface .