js/cloudmine.js
function WebService(options) {
    this.options = opts(this, options);
    if(!this.options.apiroot) this.options.apiroot = "https://api.cloudmine.io";

    var src = this.options.appid;
    if (options.savelogin) {
      if (!this.options.email) this.options.email = retrieve('email', src);
      if (!this.options.username) this.options.username = retrieve('username', src);
      if (!this.options.session_token) this.options.session_token = retrieve('session_token', src);
    }

    this.options.user_token = retrieve('ut', src) || store('ut', this.keygen(), src);
  }
function WebService(options) {
    this.options = opts(this, options);
    if(!this.options.apiroot) this.options.apiroot = "https://api.cloudmine.io";

    var src = this.options.appid;
    if (options.savelogin) {
      if (!this.options.email) this.options.email = retrieve('email', src);
      if (!this.options.username) this.options.username = retrieve('username', src);
      if (!this.options.session_token) this.options.session_token = retrieve('session_token', src);
    }

    this.options.user_token = retrieve('ut', src) || store('ut', this.keygen(), src);
  }
function WebService ( options ) { this . options = opts ( this , options ) ; if ( ! this . options . apiroot ) this . options . apiroot = "https://api.cloudmine.io" ; var src = this . options . appid ; if ( options . savelogin ) { if ( ! this . options . email ) this . options . email = retrieve ( 'email' , src ) ; if ( ! this . options . username ) this . options . username = retrieve ( 'username' , src ) ; if ( ! this . options . session_token ) this . options . session_token = retrieve ( 'session_token' , src ) ; } this . options . user_token = retrieve ( 'ut' , src ) || store ( 'ut' , this . keygen ( ) , src ) ; }
Construct a new WebService instance

<p>Each method on the WebService instance will return an APICall object which may be used to
access the results of the method called. You can chain multiple events together with the
returned object (an APICall instance).

<p>All events are at least guaranteed to have the callback signature: function(data, apicall).
supported events:
<p>   200, 201, 400, 401, 404, 409, ok, created, badrequest, unauthorized, notfound, conflict,
success, error, complete, meta, result, abort
<p>Event order: success callbacks, meta callbacks, result callbacks, error callbacks, complete
callbacks

<p>Example:
<pre class='code'>
var ws = new cloudmine.WebService({appid: "abc", apikey: "abc", appname: 'SampleApp', appversion: '1.0'});
ws.get("MyKey").on("success", function(data, apicall) {
console.log("MyKey value: %o", data["MyKey"]);
}).on("error", function(data, apicall) {
console.log("Failed to get MyKey: %o", apicall.status);
}).on("unauthorized", function(data, apicall) {
console.log("I'm not authorized to access 'appid'");
}).on(404, function(data, apicall) {
console.log("Could not find 'MyKey'");
}).on("complete", function(data, apicall) {
console.log("Finished get on 'MyKey':", data);
});
</pre>
<p>Refer to APICall's documentation for further information on events.

@param {object} Default configuration for this WebService
@config {string} [appid] The application id for requests (Required)
@config {string} [apikey] The api key for requests (Required)
@config {string} [xuniqueid] The X-Unique-ID you want to apply to all requests using this WebService (optional)
@config {string} [appname] An alphanumeric identifier for your app, used for stats purposes
@config {string} [appversion] A version identifier for you app, used for stats purposes
@config {boolean} [applevel] If true, always send requests to application.
If false, always send requests to user-level, trigger error if not logged in.
Otherwise, send requests to user-level if logged in.
@config {boolean} [savelogin] If true, session token and email / username will be persisted between logins.
@config {integer} [limit] Set the default result limit for requests
@config {string} [sort] Set the field on which to sort results
@config {integer} [skip] Set the default number of results to skip for requests
@config {boolean} [count] Return the count of results for request.
@config {string} [snippet] Run the specified code snippet during the request.
@config {string|object} [params] Parameters to give the code snippet (applies only for code snippets)
@config {boolean} [dontwait] Don't wait for the result of the code snippet (applies only for code snippets)
@config {boolean} [resultsonly] Only return results from the code snippet (applies only for code snippets)
@name WebService
@constructor
Construct a new WebService instance