mojio-js-sdk
Version:
Mojio javascript REST client.
206 lines (171 loc) • 5.18 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var MojioAuthSDK, MojioRestSDK,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
MojioAuthSDK = require('./MojioAuthSDK');
module.exports = MojioRestSDK = (function(superClass) {
var defaults;
extend(MojioRestSDK, superClass);
defaults = {
apiURL: 'api2.moj.io',
version: 'v2'
};
function MojioRestSDK(options) {
if (options == null) {
options = {};
}
MojioRestSDK.__super__.constructor.call(this, options);
}
MojioRestSDK.prototype.put = function(object_or_json_string) {
this.stateMachine.setMethod("put");
this.stateMachine.setBody_ObjectOrJson(object_or_json_string);
return this;
};
MojioRestSDK.prototype.save = function(object_model_or_json) {
this.put(object_model_or_json);
return this;
};
MojioRestSDK.prototype.update = function(object_or_json_string) {
this.put(object_or_json_string);
return this;
};
MojioRestSDK.prototype.post = function(object_or_json_string) {
this.stateMachine.setMethod("post");
this.stateMachine.setBody_ObjectOrJson(object_or_json_string);
return this;
};
MojioRestSDK.prototype.create = function(object_or_json_string) {
this.post(object_or_json_string);
return this;
};
MojioRestSDK.prototype["delete"] = function(id_or_array_of_ids) {
this.stateMachine.setMethod("delete");
this.stateMachine.setWhere(id_or_array_of_ids);
return this;
};
MojioRestSDK.prototype.destroy = function(id_or_array_of_ids) {
this["delete"](id_or_array_of_ids);
return this;
};
MojioRestSDK.prototype.get = function(id_example_or_query) {
this.stateMachine.setMethod("get");
this.stateMachine.setWhere(id_example_or_query);
return this;
};
MojioRestSDK.prototype.query = function(id_example_or_query) {
this.get(id_example_or_query);
return this;
};
MojioRestSDK.prototype.select = function(id_example_or_query) {
this.get(id_example_or_query);
return this;
};
MojioRestSDK.prototype.where = function(id_example_or_query) {
this.get(id_example_or_query);
return this;
};
MojioRestSDK.prototype.filter = function(filter) {
this.stateMachine.filter = filter;
return this;
};
MojioRestSDK.prototype.fields = function(fields) {
this.stateMachine.fields = fields;
return this;
};
MojioRestSDK.prototype.top = function(top) {
return this.limit(top);
};
MojioRestSDK.prototype.limit = function(limit) {
this.stateMachine.limit = limit;
return this;
};
MojioRestSDK.prototype.skip = function(offset) {
return this.offset(offset);
};
MojioRestSDK.prototype.offset = function(offset) {
stateMachine.offset = offset;
return this;
};
MojioRestSDK.prototype.orderby = function(field, desc) {
if (desc == null) {
desc = null;
}
stateMachine.field = field;
if (desc != null) {
stateMachine.desc = desc;
}
return this;
};
MojioRestSDK.prototype.desc = function(desc) {
if (desc == null) {
desc = null;
}
if (desc != null) {
stateMachine.desc = desc;
} else {
stateMachine.desc = true;
}
return this;
};
MojioRestSDK.prototype.asc = function(asc) {
if (asc == null) {
asc = null;
}
if (asc != null) {
stateMachine.desc = !asc;
} else {
stateMachine.desc = false;
}
return this;
};
MojioRestSDK.prototype.field = function(field, desc) {
if (desc == null) {
desc = null;
}
stateMachine.field = field;
if (desc != null) {
stateMachine.desc = desc;
}
return this;
};
MojioRestSDK.prototype.add = function(field, desc) {
if (desc == null) {
desc = null;
}
stateMachine.field = field;
if (desc != null) {
stateMachine.desc = desc;
}
return this;
};
MojioRestSDK.prototype.set = function(field, desc) {
if (desc == null) {
desc = null;
}
stateMachine.field = field;
if (desc != null) {
stateMachine.desc = desc;
}
return this;
};
MojioRestSDK.prototype.remove = function(field, desc) {
if (desc == null) {
desc = null;
}
stateMachine.field = field;
if (desc != null) {
stateMachine.desc = desc;
}
return this;
};
MojioRestSDK.prototype.revoke = function(user, callback) {
if ((callback != null)) {
this.callback(callback);
}
return this;
};
return MojioRestSDK;
})(MojioAuthSDK);
}).call(this);
//# sourceMappingURL=MojioRestSDK.js.map