Guest User

new

a guest
Oct 17th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 125.38 KB | None | 0 0
  1. !function(e) {
  2.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  3.         var f;
  4.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  5.         f.Address = e();
  6.     }
  7. }(function() {
  8.     var define, module, exports;
  9.     return function e(t, n, r) {
  10.         function s(o, u) {
  11.             if (!n[o]) {
  12.                 if (!t[o]) {
  13.                     var a = typeof require == "function" && require;
  14.                     if (!u && a) return a(o, !0);
  15.                     if (i) return i(o, !0);
  16.                     throw new Error("Cannot find module '" + o + "'");
  17.                 }
  18.                 var f = n[o] = {
  19.                     exports: {}
  20.                 };
  21.                 t[o][0].call(f.exports, function(e) {
  22.                     var n = t[o][1][e];
  23.                     return s(n ? n : e);
  24.                 }, f, f.exports, e, t, n, r);
  25.             }
  26.             return n[o].exports;
  27.         }
  28.         var i = typeof require == "function" && require;
  29.         for (var o = 0; o < r.length; o++) s(r[o]);
  30.         return s;
  31.     }({
  32.         1: [ function(_dereq_, module, exports) {
  33.             (function() {
  34.                 var Address, MojioModel, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  35.                     for (var key in parent) {
  36.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  37.                     }
  38.                     function ctor() {
  39.                         this.constructor = child;
  40.                     }
  41.                     ctor.prototype = parent.prototype;
  42.                     child.prototype = new ctor();
  43.                     child.__super__ = parent.prototype;
  44.                     return child;
  45.                 };
  46.                 MojioModel = _dereq_("./MojioModel");
  47.                 module.exports = Address = function(_super) {
  48.                     __extends(Address, _super);
  49.                     Address.prototype._schema = {
  50.                         Address1: "String",
  51.                         Address2: "String",
  52.                         City: "String",
  53.                         State: "String",
  54.                         Zip: "String",
  55.                         Country: "String"
  56.                     };
  57.                     Address.prototype._resource = "Addresss";
  58.                     Address.prototype._model = "Address";
  59.                     function Address(json) {
  60.                         Address.__super__.constructor.call(this, json);
  61.                     }
  62.                     Address._resource = "Addresss";
  63.                     Address._model = "Address";
  64.                     Address.resource = function() {
  65.                         return Address._resource;
  66.                     };
  67.                     Address.model = function() {
  68.                         return Address._model;
  69.                     };
  70.                     return Address;
  71.                 }(MojioModel);
  72.             }).call(this);
  73.         }, {
  74.             "./MojioModel": 2
  75.         } ],
  76.         2: [ function(_dereq_, module, exports) {
  77.             (function() {
  78.                 var MojioModel;
  79.                 module.exports = MojioModel = function() {
  80.                     MojioModel._resource = "Schema";
  81.                     MojioModel._model = "Model";
  82.                     function MojioModel(json) {
  83.                         this._client = null;
  84.                         this.validate(json);
  85.                     }
  86.                     MojioModel.prototype.setField = function(field, value) {
  87.                         this[field] = value;
  88.                         return this[field];
  89.                     };
  90.                     MojioModel.prototype.getField = function(field) {
  91.                         return this[field];
  92.                     };
  93.                     MojioModel.prototype.validate = function(json) {
  94.                         var field, value, _results;
  95.                         _results = [];
  96.                         for (field in json) {
  97.                             value = json[field];
  98.                             _results.push(this.setField(field, value));
  99.                         }
  100.                         return _results;
  101.                     };
  102.                     MojioModel.prototype.stringify = function() {
  103.                         return JSON.stringify(this, this.replacer);
  104.                     };
  105.                     MojioModel.prototype.replacer = function(key, value) {
  106.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  107.                             return void 0;
  108.                         } else {
  109.                             return value;
  110.                         }
  111.                     };
  112.                     MojioModel.prototype.query = function(criteria, callback) {
  113.                         var property, query_criteria, value;
  114.                         if (this._client === null) {
  115.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  116.                             return;
  117.                         }
  118.                         if (criteria instanceof Object) {
  119.                             if (criteria.criteria == null) {
  120.                                 query_criteria = "";
  121.                                 for (property in criteria) {
  122.                                     value = criteria[property];
  123.                                     query_criteria += "" + property + "=" + value + ";";
  124.                                 }
  125.                                 criteria = {
  126.                                     criteria: query_criteria
  127.                                 };
  128.                             }
  129.                             return this._client.request({
  130.                                 method: "GET",
  131.                                 resource: this.resource(),
  132.                                 parameters: criteria
  133.                             }, function(_this) {
  134.                                 return function(error, result) {
  135.                                     return callback(error, _this._client.model(_this.model(), result));
  136.                                 };
  137.                             }(this));
  138.                         } else if (typeof criteria === "string") {
  139.                             return this._client.request({
  140.                                 method: "GET",
  141.                                 resource: this.resource(),
  142.                                 parameters: {
  143.                                     id: criteria
  144.                                 }
  145.                             }, function(_this) {
  146.                                 return function(error, result) {
  147.                                     return callback(error, _this._client.model(_this.model(), result));
  148.                                 };
  149.                             }(this));
  150.                         } else {
  151.                             return callback("criteria given is not in understood format, string or object.", null);
  152.                         }
  153.                     };
  154.                     MojioModel.prototype.get = function(criteria, callback) {
  155.                         return this.query(criteria, callback);
  156.                     };
  157.                     MojioModel.prototype.create = function(callback) {
  158.                         if (this._client === null) {
  159.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  160.                             return;
  161.                         }
  162.                         return this._client.request({
  163.                             method: "POST",
  164.                             resource: this.resource(),
  165.                             body: this.stringify()
  166.                         }, callback);
  167.                     };
  168.                     MojioModel.prototype.post = function(callback) {
  169.                         return this.create(callback);
  170.                     };
  171.                     MojioModel.prototype.save = function(callback) {
  172.                         if (this._client === null) {
  173.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  174.                             return;
  175.                         }
  176.                         return this._client.request({
  177.                             method: "PUT",
  178.                             resource: this.resource(),
  179.                             body: this.stringify(),
  180.                             parameters: {
  181.                                 id: this._id
  182.                             }
  183.                         }, callback);
  184.                     };
  185.                     MojioModel.prototype.put = function(callback) {
  186.                         return this.save(callback);
  187.                     };
  188.                     MojioModel.prototype["delete"] = function(callback) {
  189.                         return this._client.request({
  190.                             method: "DELETE",
  191.                             resource: this.resource(),
  192.                             parameters: {
  193.                                 id: this._id
  194.                             }
  195.                         }, callback);
  196.                     };
  197.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  198.                         if (subject == null) {
  199.                             subject = null;
  200.                         }
  201.                         return this._client.observe(object, subject, observer_callback, callback);
  202.                     };
  203.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  204.                         if (subject == null) {
  205.                             subject = null;
  206.                         }
  207.                         return this._client.observe(object, subject, observer_callback, callback);
  208.                     };
  209.                     MojioModel.prototype.store = function(model, key, value, callback) {
  210.                         return this._client.store(model, key, value, callback);
  211.                     };
  212.                     MojioModel.prototype.storage = function(model, key, callback) {
  213.                         return this._client.storage(model, key, callback);
  214.                     };
  215.                     MojioModel.prototype.unstore = function(model, key, callback) {
  216.                         return this._client.unstore(model, key, callback);
  217.                     };
  218.                     MojioModel.prototype.statistic = function(expression, callback) {
  219.                         return callback(null, true);
  220.                     };
  221.                     MojioModel.prototype.resource = function() {
  222.                         return this._resource;
  223.                     };
  224.                     MojioModel.prototype.model = function() {
  225.                         return this._model;
  226.                     };
  227.                     MojioModel.prototype.schema = function() {
  228.                         return this._schema;
  229.                     };
  230.                     MojioModel.prototype.authorization = function(client) {
  231.                         this._client = client;
  232.                         return this;
  233.                     };
  234.                     MojioModel.prototype.id = function() {
  235.                         return this._id;
  236.                     };
  237.                     MojioModel.prototype.mock = function(type, withid) {
  238.                         var field, value, _ref;
  239.                         if (withid == null) {
  240.                             withid = false;
  241.                         }
  242.                         _ref = this.schema();
  243.                         for (field in _ref) {
  244.                             value = _ref[field];
  245.                             if (field === "Type") {
  246.                                 this.setField(field, this.model());
  247.                             } else if (field === "UserName") {
  248.                                 this.setField(field, "Tester");
  249.                             } else if (field === "Email") {
  250.                                 this.setField(field, "test@moj.io");
  251.                             } else if (field === "Password") {
  252.                                 this.setField(field, "Password007!");
  253.                             } else if (field !== "_id" || withid) {
  254.                                 switch (value) {
  255.                                   case "Integer":
  256.                                     this.setField(field, "0");
  257.                                     break;
  258.  
  259.                                   case "Boolean":
  260.                                     this.setField(field, false);
  261.                                     break;
  262.  
  263.                                   case "String":
  264.                                     this.setField(field, "test" + Math.random());
  265.                                 }
  266.                             }
  267.                         }
  268.                         return this;
  269.                     };
  270.                     return MojioModel;
  271.                 }();
  272.             }).call(this);
  273.         }, {} ]
  274.     }, {}, [ 1 ])(1);
  275. });
  276.  
  277. !function(e) {
  278.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  279.         var f;
  280.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  281.         f.App = e();
  282.     }
  283. }(function() {
  284.     var define, module, exports;
  285.     return function e(t, n, r) {
  286.         function s(o, u) {
  287.             if (!n[o]) {
  288.                 if (!t[o]) {
  289.                     var a = typeof require == "function" && require;
  290.                     if (!u && a) return a(o, !0);
  291.                     if (i) return i(o, !0);
  292.                     throw new Error("Cannot find module '" + o + "'");
  293.                 }
  294.                 var f = n[o] = {
  295.                     exports: {}
  296.                 };
  297.                 t[o][0].call(f.exports, function(e) {
  298.                     var n = t[o][1][e];
  299.                     return s(n ? n : e);
  300.                 }, f, f.exports, e, t, n, r);
  301.             }
  302.             return n[o].exports;
  303.         }
  304.         var i = typeof require == "function" && require;
  305.         for (var o = 0; o < r.length; o++) s(r[o]);
  306.         return s;
  307.     }({
  308.         1: [ function(_dereq_, module, exports) {
  309.             (function() {
  310.                 var App, MojioModel, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  311.                     for (var key in parent) {
  312.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  313.                     }
  314.                     function ctor() {
  315.                         this.constructor = child;
  316.                     }
  317.                     ctor.prototype = parent.prototype;
  318.                     child.prototype = new ctor();
  319.                     child.__super__ = parent.prototype;
  320.                     return child;
  321.                 };
  322.                 MojioModel = _dereq_("./MojioModel");
  323.                 module.exports = App = function(_super) {
  324.                     __extends(App, _super);
  325.                     App.prototype._schema = {
  326.                         Type: "String",
  327.                         Name: "String",
  328.                         Description: "String",
  329.                         CreationDate: "String",
  330.                         Downloads: "Integer",
  331.                         RedirectUris: "String",
  332.                         ApplicationType: "String",
  333.                         _id: "String",
  334.                         _deleted: "Boolean"
  335.                     };
  336.                     App.prototype._resource = "Apps";
  337.                     App.prototype._model = "App";
  338.                     function App(json) {
  339.                         App.__super__.constructor.call(this, json);
  340.                     }
  341.                     App._resource = "Apps";
  342.                     App._model = "App";
  343.                     App.resource = function() {
  344.                         return App._resource;
  345.                     };
  346.                     App.model = function() {
  347.                         return App._model;
  348.                     };
  349.                     return App;
  350.                 }(MojioModel);
  351.             }).call(this);
  352.         }, {
  353.             "./MojioModel": 2
  354.         } ],
  355.         2: [ function(_dereq_, module, exports) {
  356.             (function() {
  357.                 var MojioModel;
  358.                 module.exports = MojioModel = function() {
  359.                     MojioModel._resource = "Schema";
  360.                     MojioModel._model = "Model";
  361.                     function MojioModel(json) {
  362.                         this._client = null;
  363.                         this.validate(json);
  364.                     }
  365.                     MojioModel.prototype.setField = function(field, value) {
  366.                         this[field] = value;
  367.                         return this[field];
  368.                     };
  369.                     MojioModel.prototype.getField = function(field) {
  370.                         return this[field];
  371.                     };
  372.                     MojioModel.prototype.validate = function(json) {
  373.                         var field, value, _results;
  374.                         _results = [];
  375.                         for (field in json) {
  376.                             value = json[field];
  377.                             _results.push(this.setField(field, value));
  378.                         }
  379.                         return _results;
  380.                     };
  381.                     MojioModel.prototype.stringify = function() {
  382.                         return JSON.stringify(this, this.replacer);
  383.                     };
  384.                     MojioModel.prototype.replacer = function(key, value) {
  385.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  386.                             return void 0;
  387.                         } else {
  388.                             return value;
  389.                         }
  390.                     };
  391.                     MojioModel.prototype.query = function(criteria, callback) {
  392.                         var property, query_criteria, value;
  393.                         if (this._client === null) {
  394.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  395.                             return;
  396.                         }
  397.                         if (criteria instanceof Object) {
  398.                             if (criteria.criteria == null) {
  399.                                 query_criteria = "";
  400.                                 for (property in criteria) {
  401.                                     value = criteria[property];
  402.                                     query_criteria += "" + property + "=" + value + ";";
  403.                                 }
  404.                                 criteria = {
  405.                                     criteria: query_criteria
  406.                                 };
  407.                             }
  408.                             return this._client.request({
  409.                                 method: "GET",
  410.                                 resource: this.resource(),
  411.                                 parameters: criteria
  412.                             }, function(_this) {
  413.                                 return function(error, result) {
  414.                                     return callback(error, _this._client.model(_this.model(), result));
  415.                                 };
  416.                             }(this));
  417.                         } else if (typeof criteria === "string") {
  418.                             return this._client.request({
  419.                                 method: "GET",
  420.                                 resource: this.resource(),
  421.                                 parameters: {
  422.                                     id: criteria
  423.                                 }
  424.                             }, function(_this) {
  425.                                 return function(error, result) {
  426.                                     return callback(error, _this._client.model(_this.model(), result));
  427.                                 };
  428.                             }(this));
  429.                         } else {
  430.                             return callback("criteria given is not in understood format, string or object.", null);
  431.                         }
  432.                     };
  433.                     MojioModel.prototype.get = function(criteria, callback) {
  434.                         return this.query(criteria, callback);
  435.                     };
  436.                     MojioModel.prototype.create = function(callback) {
  437.                         if (this._client === null) {
  438.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  439.                             return;
  440.                         }
  441.                         return this._client.request({
  442.                             method: "POST",
  443.                             resource: this.resource(),
  444.                             body: this.stringify()
  445.                         }, callback);
  446.                     };
  447.                     MojioModel.prototype.post = function(callback) {
  448.                         return this.create(callback);
  449.                     };
  450.                     MojioModel.prototype.save = function(callback) {
  451.                         if (this._client === null) {
  452.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  453.                             return;
  454.                         }
  455.                         return this._client.request({
  456.                             method: "PUT",
  457.                             resource: this.resource(),
  458.                             body: this.stringify(),
  459.                             parameters: {
  460.                                 id: this._id
  461.                             }
  462.                         }, callback);
  463.                     };
  464.                     MojioModel.prototype.put = function(callback) {
  465.                         return this.save(callback);
  466.                     };
  467.                     MojioModel.prototype["delete"] = function(callback) {
  468.                         return this._client.request({
  469.                             method: "DELETE",
  470.                             resource: this.resource(),
  471.                             parameters: {
  472.                                 id: this._id
  473.                             }
  474.                         }, callback);
  475.                     };
  476.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  477.                         if (subject == null) {
  478.                             subject = null;
  479.                         }
  480.                         return this._client.observe(object, subject, observer_callback, callback);
  481.                     };
  482.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  483.                         if (subject == null) {
  484.                             subject = null;
  485.                         }
  486.                         return this._client.observe(object, subject, observer_callback, callback);
  487.                     };
  488.                     MojioModel.prototype.store = function(model, key, value, callback) {
  489.                         return this._client.store(model, key, value, callback);
  490.                     };
  491.                     MojioModel.prototype.storage = function(model, key, callback) {
  492.                         return this._client.storage(model, key, callback);
  493.                     };
  494.                     MojioModel.prototype.unstore = function(model, key, callback) {
  495.                         return this._client.unstore(model, key, callback);
  496.                     };
  497.                     MojioModel.prototype.statistic = function(expression, callback) {
  498.                         return callback(null, true);
  499.                     };
  500.                     MojioModel.prototype.resource = function() {
  501.                         return this._resource;
  502.                     };
  503.                     MojioModel.prototype.model = function() {
  504.                         return this._model;
  505.                     };
  506.                     MojioModel.prototype.schema = function() {
  507.                         return this._schema;
  508.                     };
  509.                     MojioModel.prototype.authorization = function(client) {
  510.                         this._client = client;
  511.                         return this;
  512.                     };
  513.                     MojioModel.prototype.id = function() {
  514.                         return this._id;
  515.                     };
  516.                     MojioModel.prototype.mock = function(type, withid) {
  517.                         var field, value, _ref;
  518.                         if (withid == null) {
  519.                             withid = false;
  520.                         }
  521.                         _ref = this.schema();
  522.                         for (field in _ref) {
  523.                             value = _ref[field];
  524.                             if (field === "Type") {
  525.                                 this.setField(field, this.model());
  526.                             } else if (field === "UserName") {
  527.                                 this.setField(field, "Tester");
  528.                             } else if (field === "Email") {
  529.                                 this.setField(field, "test@moj.io");
  530.                             } else if (field === "Password") {
  531.                                 this.setField(field, "Password007!");
  532.                             } else if (field !== "_id" || withid) {
  533.                                 switch (value) {
  534.                                   case "Integer":
  535.                                     this.setField(field, "0");
  536.                                     break;
  537.  
  538.                                   case "Boolean":
  539.                                     this.setField(field, false);
  540.                                     break;
  541.  
  542.                                   case "String":
  543.                                     this.setField(field, "test" + Math.random());
  544.                                 }
  545.                             }
  546.                         }
  547.                         return this;
  548.                     };
  549.                     return MojioModel;
  550.                 }();
  551.             }).call(this);
  552.         }, {} ]
  553.     }, {}, [ 1 ])(1);
  554. });
  555.  
  556. !function(e) {
  557.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  558.         var f;
  559.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  560.         f.Event = e();
  561.     }
  562. }(function() {
  563.     var define, module, exports;
  564.     return function e(t, n, r) {
  565.         function s(o, u) {
  566.             if (!n[o]) {
  567.                 if (!t[o]) {
  568.                     var a = typeof require == "function" && require;
  569.                     if (!u && a) return a(o, !0);
  570.                     if (i) return i(o, !0);
  571.                     throw new Error("Cannot find module '" + o + "'");
  572.                 }
  573.                 var f = n[o] = {
  574.                     exports: {}
  575.                 };
  576.                 t[o][0].call(f.exports, function(e) {
  577.                     var n = t[o][1][e];
  578.                     return s(n ? n : e);
  579.                 }, f, f.exports, e, t, n, r);
  580.             }
  581.             return n[o].exports;
  582.         }
  583.         var i = typeof require == "function" && require;
  584.         for (var o = 0; o < r.length; o++) s(r[o]);
  585.         return s;
  586.     }({
  587.         1: [ function(_dereq_, module, exports) {
  588.             (function() {
  589.                 var Event, MojioModel, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  590.                     for (var key in parent) {
  591.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  592.                     }
  593.                     function ctor() {
  594.                         this.constructor = child;
  595.                     }
  596.                     ctor.prototype = parent.prototype;
  597.                     child.prototype = new ctor();
  598.                     child.__super__ = parent.prototype;
  599.                     return child;
  600.                 };
  601.                 MojioModel = _dereq_("./MojioModel");
  602.                 module.exports = Event = function(_super) {
  603.                     __extends(Event, _super);
  604.                     Event.prototype._schema = {
  605.                         Type: "Integer",
  606.                         MojioId: "String",
  607.                         VehicleId: "String",
  608.                         OwnerId: "String",
  609.                         EventType: "Integer",
  610.                         Time: "String",
  611.                         Location: "Object",
  612.                         TimeIsApprox: "Boolean",
  613.                         BatteryVoltage: "Float",
  614.                         ConnectionLost: "Boolean",
  615.                         _id: "String",
  616.                         _deleted: "Boolean",
  617.                         Accelerometer: "Object",
  618.                         TripId: "String",
  619.                         Altitude: "Float",
  620.                         Heading: "Float",
  621.                         Distance: "Float",
  622.                         FuelLevel: "Float",
  623.                         FuelEfficiency: "Float",
  624.                         Speed: "Float",
  625.                         Acceleration: "Float",
  626.                         Deceleration: "Float",
  627.                         Odometer: "Float",
  628.                         RPM: "Integer",
  629.                         DTCs: "Array",
  630.                         MilStatus: "Boolean",
  631.                         Force: "Float",
  632.                         MaxSpeed: "Float",
  633.                         AverageSpeed: "Float",
  634.                         MovingTime: "Float",
  635.                         IdleTime: "Float",
  636.                         StopTime: "Float",
  637.                         MaxRPM: "Float",
  638.                         EventTypes: "Array",
  639.                         Timing: "Integer",
  640.                         Name: "String",
  641.                         ObserverType: "Integer",
  642.                         AppId: "String",
  643.                         Parent: "String",
  644.                         ParentId: "String",
  645.                         Subject: "String",
  646.                         SubjectId: "String",
  647.                         Transports: "Integer",
  648.                         Status: "Integer",
  649.                         Tokens: "Array"
  650.                     };
  651.                     Event.prototype._resource = "Events";
  652.                     Event.prototype._model = "Event";
  653.                     function Event(json) {
  654.                         Event.__super__.constructor.call(this, json);
  655.                     }
  656.                     Event._resource = "Events";
  657.                     Event._model = "Event";
  658.                     Event.resource = function() {
  659.                         return Event._resource;
  660.                     };
  661.                     Event.model = function() {
  662.                         return Event._model;
  663.                     };
  664.                     return Event;
  665.                 }(MojioModel);
  666.             }).call(this);
  667.         }, {
  668.             "./MojioModel": 2
  669.         } ],
  670.         2: [ function(_dereq_, module, exports) {
  671.             (function() {
  672.                 var MojioModel;
  673.                 module.exports = MojioModel = function() {
  674.                     MojioModel._resource = "Schema";
  675.                     MojioModel._model = "Model";
  676.                     function MojioModel(json) {
  677.                         this._client = null;
  678.                         this.validate(json);
  679.                     }
  680.                     MojioModel.prototype.setField = function(field, value) {
  681.                         this[field] = value;
  682.                         return this[field];
  683.                     };
  684.                     MojioModel.prototype.getField = function(field) {
  685.                         return this[field];
  686.                     };
  687.                     MojioModel.prototype.validate = function(json) {
  688.                         var field, value, _results;
  689.                         _results = [];
  690.                         for (field in json) {
  691.                             value = json[field];
  692.                             _results.push(this.setField(field, value));
  693.                         }
  694.                         return _results;
  695.                     };
  696.                     MojioModel.prototype.stringify = function() {
  697.                         return JSON.stringify(this, this.replacer);
  698.                     };
  699.                     MojioModel.prototype.replacer = function(key, value) {
  700.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  701.                             return void 0;
  702.                         } else {
  703.                             return value;
  704.                         }
  705.                     };
  706.                     MojioModel.prototype.query = function(criteria, callback) {
  707.                         var property, query_criteria, value;
  708.                         if (this._client === null) {
  709.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  710.                             return;
  711.                         }
  712.                         if (criteria instanceof Object) {
  713.                             if (criteria.criteria == null) {
  714.                                 query_criteria = "";
  715.                                 for (property in criteria) {
  716.                                     value = criteria[property];
  717.                                     query_criteria += "" + property + "=" + value + ";";
  718.                                 }
  719.                                 criteria = {
  720.                                     criteria: query_criteria
  721.                                 };
  722.                             }
  723.                             return this._client.request({
  724.                                 method: "GET",
  725.                                 resource: this.resource(),
  726.                                 parameters: criteria
  727.                             }, function(_this) {
  728.                                 return function(error, result) {
  729.                                     return callback(error, _this._client.model(_this.model(), result));
  730.                                 };
  731.                             }(this));
  732.                         } else if (typeof criteria === "string") {
  733.                             return this._client.request({
  734.                                 method: "GET",
  735.                                 resource: this.resource(),
  736.                                 parameters: {
  737.                                     id: criteria
  738.                                 }
  739.                             }, function(_this) {
  740.                                 return function(error, result) {
  741.                                     return callback(error, _this._client.model(_this.model(), result));
  742.                                 };
  743.                             }(this));
  744.                         } else {
  745.                             return callback("criteria given is not in understood format, string or object.", null);
  746.                         }
  747.                     };
  748.                     MojioModel.prototype.get = function(criteria, callback) {
  749.                         return this.query(criteria, callback);
  750.                     };
  751.                     MojioModel.prototype.create = function(callback) {
  752.                         if (this._client === null) {
  753.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  754.                             return;
  755.                         }
  756.                         return this._client.request({
  757.                             method: "POST",
  758.                             resource: this.resource(),
  759.                             body: this.stringify()
  760.                         }, callback);
  761.                     };
  762.                     MojioModel.prototype.post = function(callback) {
  763.                         return this.create(callback);
  764.                     };
  765.                     MojioModel.prototype.save = function(callback) {
  766.                         if (this._client === null) {
  767.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  768.                             return;
  769.                         }
  770.                         return this._client.request({
  771.                             method: "PUT",
  772.                             resource: this.resource(),
  773.                             body: this.stringify(),
  774.                             parameters: {
  775.                                 id: this._id
  776.                             }
  777.                         }, callback);
  778.                     };
  779.                     MojioModel.prototype.put = function(callback) {
  780.                         return this.save(callback);
  781.                     };
  782.                     MojioModel.prototype["delete"] = function(callback) {
  783.                         return this._client.request({
  784.                             method: "DELETE",
  785.                             resource: this.resource(),
  786.                             parameters: {
  787.                                 id: this._id
  788.                             }
  789.                         }, callback);
  790.                     };
  791.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  792.                         if (subject == null) {
  793.                             subject = null;
  794.                         }
  795.                         return this._client.observe(object, subject, observer_callback, callback);
  796.                     };
  797.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  798.                         if (subject == null) {
  799.                             subject = null;
  800.                         }
  801.                         return this._client.observe(object, subject, observer_callback, callback);
  802.                     };
  803.                     MojioModel.prototype.store = function(model, key, value, callback) {
  804.                         return this._client.store(model, key, value, callback);
  805.                     };
  806.                     MojioModel.prototype.storage = function(model, key, callback) {
  807.                         return this._client.storage(model, key, callback);
  808.                     };
  809.                     MojioModel.prototype.unstore = function(model, key, callback) {
  810.                         return this._client.unstore(model, key, callback);
  811.                     };
  812.                     MojioModel.prototype.statistic = function(expression, callback) {
  813.                         return callback(null, true);
  814.                     };
  815.                     MojioModel.prototype.resource = function() {
  816.                         return this._resource;
  817.                     };
  818.                     MojioModel.prototype.model = function() {
  819.                         return this._model;
  820.                     };
  821.                     MojioModel.prototype.schema = function() {
  822.                         return this._schema;
  823.                     };
  824.                     MojioModel.prototype.authorization = function(client) {
  825.                         this._client = client;
  826.                         return this;
  827.                     };
  828.                     MojioModel.prototype.id = function() {
  829.                         return this._id;
  830.                     };
  831.                     MojioModel.prototype.mock = function(type, withid) {
  832.                         var field, value, _ref;
  833.                         if (withid == null) {
  834.                             withid = false;
  835.                         }
  836.                         _ref = this.schema();
  837.                         for (field in _ref) {
  838.                             value = _ref[field];
  839.                             if (field === "Type") {
  840.                                 this.setField(field, this.model());
  841.                             } else if (field === "UserName") {
  842.                                 this.setField(field, "Tester");
  843.                             } else if (field === "Email") {
  844.                                 this.setField(field, "test@moj.io");
  845.                             } else if (field === "Password") {
  846.                                 this.setField(field, "Password007!");
  847.                             } else if (field !== "_id" || withid) {
  848.                                 switch (value) {
  849.                                   case "Integer":
  850.                                     this.setField(field, "0");
  851.                                     break;
  852.  
  853.                                   case "Boolean":
  854.                                     this.setField(field, false);
  855.                                     break;
  856.  
  857.                                   case "String":
  858.                                     this.setField(field, "test" + Math.random());
  859.                                 }
  860.                             }
  861.                         }
  862.                         return this;
  863.                     };
  864.                     return MojioModel;
  865.                 }();
  866.             }).call(this);
  867.         }, {} ]
  868.     }, {}, [ 1 ])(1);
  869. });
  870.  
  871. !function(e) {
  872.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  873.         var o;
  874.         "undefined" != typeof window ? o = window : "undefined" != typeof global ? o = global : "undefined" != typeof self && (o = self),
  875.         o.Location = e();
  876.     }
  877. }(function() {
  878.     var define, module, exports;
  879.     return function e(t, n, r) {
  880.         function s(o, u) {
  881.             if (!n[o]) {
  882.                 if (!t[o]) {
  883.                     var a = typeof require == "function" && require;
  884.                     if (!u && a) return a(o, !0);
  885.                     if (i) return i(o, !0);
  886.                     throw new Error("Cannot find module '" + o + "'");
  887.                 }
  888.                 var f = n[o] = {
  889.                     exports: {}
  890.                 };
  891.                 t[o][0].call(f.exports, function(e) {
  892.                     var n = t[o][1][e];
  893.                     return s(n ? n : e);
  894.                 }, f, f.exports, e, t, n, r);
  895.             }
  896.             return n[o].exports;
  897.         }
  898.         var i = typeof require == "function" && require;
  899.         for (var o = 0; o < r.length; o++) s(r[o]);
  900.         return s;
  901.     }({
  902.         1: [ function(_dereq_, module, exports) {
  903.             (function() {
  904.                 var Location, MojioModel, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  905.                     for (var key in parent) {
  906.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  907.                     }
  908.                     function ctor() {
  909.                         this.constructor = child;
  910.                     }
  911.                     ctor.prototype = parent.prototype;
  912.                     child.prototype = new ctor();
  913.                     child.__super__ = parent.prototype;
  914.                     return child;
  915.                 };
  916.                 MojioModel = _dereq_("./MojioModel");
  917.                 module.exports = Location = function(_super) {
  918.                     __extends(Location, _super);
  919.                     Location.prototype._schema = {
  920.                         Lat: "Float",
  921.                         Lng: "Float",
  922.                         FromLockedGPS: "Boolean",
  923.                         Dilution: "Float",
  924.                         IsValid: "Boolean"
  925.                     };
  926.                     Location.prototype._resource = "Locations";
  927.                     Location.prototype._model = "Location";
  928.                     function Location(json) {
  929.                         Location.__super__.constructor.call(this, json);
  930.                     }
  931.                     Location._resource = "Locations";
  932.                     Location._model = "Location";
  933.                     Location.resource = function() {
  934.                         return Location._resource;
  935.                     };
  936.                     Location.model = function() {
  937.                         return Location._model;
  938.                     };
  939.                     return Location;
  940.                 }(MojioModel);
  941.             }).call(this);
  942.         }, {
  943.             "./MojioModel": 2
  944.         } ],
  945.         2: [ function(_dereq_, module, exports) {
  946.             (function() {
  947.                 var MojioModel;
  948.                 module.exports = MojioModel = function() {
  949.                     MojioModel._resource = "Schema";
  950.                     MojioModel._model = "Model";
  951.                     function MojioModel(json) {
  952.                         this._client = null;
  953.                         this.validate(json);
  954.                     }
  955.                     MojioModel.prototype.setField = function(field, value) {
  956.                         this[field] = value;
  957.                         return this[field];
  958.                     };
  959.                     MojioModel.prototype.getField = function(field) {
  960.                         return this[field];
  961.                     };
  962.                     MojioModel.prototype.validate = function(json) {
  963.                         var field, value, _results;
  964.                         _results = [];
  965.                         for (field in json) {
  966.                             value = json[field];
  967.                             _results.push(this.setField(field, value));
  968.                         }
  969.                         return _results;
  970.                     };
  971.                     MojioModel.prototype.stringify = function() {
  972.                         return JSON.stringify(this, this.replacer);
  973.                     };
  974.                     MojioModel.prototype.replacer = function(key, value) {
  975.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  976.                             return void 0;
  977.                         } else {
  978.                             return value;
  979.                         }
  980.                     };
  981.                     MojioModel.prototype.query = function(criteria, callback) {
  982.                         var property, query_criteria, value;
  983.                         if (this._client === null) {
  984.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  985.                             return;
  986.                         }
  987.                         if (criteria instanceof Object) {
  988.                             if (criteria.criteria == null) {
  989.                                 query_criteria = "";
  990.                                 for (property in criteria) {
  991.                                     value = criteria[property];
  992.                                     query_criteria += "" + property + "=" + value + ";";
  993.                                 }
  994.                                 criteria = {
  995.                                     criteria: query_criteria
  996.                                 };
  997.                             }
  998.                             return this._client.request({
  999.                                 method: "GET",
  1000.                                 resource: this.resource(),
  1001.                                 parameters: criteria
  1002.                             }, function(_this) {
  1003.                                 return function(error, result) {
  1004.                                     return callback(error, _this._client.model(_this.model(), result));
  1005.                                 };
  1006.                             }(this));
  1007.                         } else if (typeof criteria === "string") {
  1008.                             return this._client.request({
  1009.                                 method: "GET",
  1010.                                 resource: this.resource(),
  1011.                                 parameters: {
  1012.                                     id: criteria
  1013.                                 }
  1014.                             }, function(_this) {
  1015.                                 return function(error, result) {
  1016.                                     return callback(error, _this._client.model(_this.model(), result));
  1017.                                 };
  1018.                             }(this));
  1019.                         } else {
  1020.                             return callback("criteria given is not in understood format, string or object.", null);
  1021.                         }
  1022.                     };
  1023.                     MojioModel.prototype.get = function(criteria, callback) {
  1024.                         return this.query(criteria, callback);
  1025.                     };
  1026.                     MojioModel.prototype.create = function(callback) {
  1027.                         if (this._client === null) {
  1028.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1029.                             return;
  1030.                         }
  1031.                         return this._client.request({
  1032.                             method: "POST",
  1033.                             resource: this.resource(),
  1034.                             body: this.stringify()
  1035.                         }, callback);
  1036.                     };
  1037.                     MojioModel.prototype.post = function(callback) {
  1038.                         return this.create(callback);
  1039.                     };
  1040.                     MojioModel.prototype.save = function(callback) {
  1041.                         if (this._client === null) {
  1042.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1043.                             return;
  1044.                         }
  1045.                         return this._client.request({
  1046.                             method: "PUT",
  1047.                             resource: this.resource(),
  1048.                             body: this.stringify(),
  1049.                             parameters: {
  1050.                                 id: this._id
  1051.                             }
  1052.                         }, callback);
  1053.                     };
  1054.                     MojioModel.prototype.put = function(callback) {
  1055.                         return this.save(callback);
  1056.                     };
  1057.                     MojioModel.prototype["delete"] = function(callback) {
  1058.                         return this._client.request({
  1059.                             method: "DELETE",
  1060.                             resource: this.resource(),
  1061.                             parameters: {
  1062.                                 id: this._id
  1063.                             }
  1064.                         }, callback);
  1065.                     };
  1066.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  1067.                         if (subject == null) {
  1068.                             subject = null;
  1069.                         }
  1070.                         return this._client.observe(object, subject, observer_callback, callback);
  1071.                     };
  1072.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  1073.                         if (subject == null) {
  1074.                             subject = null;
  1075.                         }
  1076.                         return this._client.observe(object, subject, observer_callback, callback);
  1077.                     };
  1078.                     MojioModel.prototype.store = function(model, key, value, callback) {
  1079.                         return this._client.store(model, key, value, callback);
  1080.                     };
  1081.                     MojioModel.prototype.storage = function(model, key, callback) {
  1082.                         return this._client.storage(model, key, callback);
  1083.                     };
  1084.                     MojioModel.prototype.unstore = function(model, key, callback) {
  1085.                         return this._client.unstore(model, key, callback);
  1086.                     };
  1087.                     MojioModel.prototype.statistic = function(expression, callback) {
  1088.                         return callback(null, true);
  1089.                     };
  1090.                     MojioModel.prototype.resource = function() {
  1091.                         return this._resource;
  1092.                     };
  1093.                     MojioModel.prototype.model = function() {
  1094.                         return this._model;
  1095.                     };
  1096.                     MojioModel.prototype.schema = function() {
  1097.                         return this._schema;
  1098.                     };
  1099.                     MojioModel.prototype.authorization = function(client) {
  1100.                         this._client = client;
  1101.                         return this;
  1102.                     };
  1103.                     MojioModel.prototype.id = function() {
  1104.                         return this._id;
  1105.                     };
  1106.                     MojioModel.prototype.mock = function(type, withid) {
  1107.                         var field, value, _ref;
  1108.                         if (withid == null) {
  1109.                             withid = false;
  1110.                         }
  1111.                         _ref = this.schema();
  1112.                         for (field in _ref) {
  1113.                             value = _ref[field];
  1114.                             if (field === "Type") {
  1115.                                 this.setField(field, this.model());
  1116.                             } else if (field === "UserName") {
  1117.                                 this.setField(field, "Tester");
  1118.                             } else if (field === "Email") {
  1119.                                 this.setField(field, "test@moj.io");
  1120.                             } else if (field === "Password") {
  1121.                                 this.setField(field, "Password007!");
  1122.                             } else if (field !== "_id" || withid) {
  1123.                                 switch (value) {
  1124.                                   case "Integer":
  1125.                                     this.setField(field, "0");
  1126.                                     break;
  1127.  
  1128.                                   case "Boolean":
  1129.                                     this.setField(field, false);
  1130.                                     break;
  1131.  
  1132.                                   case "String":
  1133.                                     this.setField(field, "test" + Math.random());
  1134.                                 }
  1135.                             }
  1136.                         }
  1137.                         return this;
  1138.                     };
  1139.                     return MojioModel;
  1140.                 }();
  1141.             }).call(this);
  1142.         }, {} ]
  1143.     }, {}, [ 1 ])(1);
  1144. });
  1145.  
  1146. !function(e) {
  1147.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  1148.         var o;
  1149.         "undefined" != typeof window ? o = window : "undefined" != typeof global ? o = global : "undefined" != typeof self && (o = self),
  1150.         o.Mojio = e();
  1151.     }
  1152. }(function() {
  1153.     var define, module, exports;
  1154.     return function e(t, n, r) {
  1155.         function s(o, u) {
  1156.             if (!n[o]) {
  1157.                 if (!t[o]) {
  1158.                     var a = typeof require == "function" && require;
  1159.                     if (!u && a) return a(o, !0);
  1160.                     if (i) return i(o, !0);
  1161.                     throw new Error("Cannot find module '" + o + "'");
  1162.                 }
  1163.                 var f = n[o] = {
  1164.                     exports: {}
  1165.                 };
  1166.                 t[o][0].call(f.exports, function(e) {
  1167.                     var n = t[o][1][e];
  1168.                     return s(n ? n : e);
  1169.                 }, f, f.exports, e, t, n, r);
  1170.             }
  1171.             return n[o].exports;
  1172.         }
  1173.         var i = typeof require == "function" && require;
  1174.         for (var o = 0; o < r.length; o++) s(r[o]);
  1175.         return s;
  1176.     }({
  1177.         1: [ function(_dereq_, module, exports) {
  1178.             (function() {
  1179.                 var Mojio, MojioModel, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  1180.                     for (var key in parent) {
  1181.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  1182.                     }
  1183.                     function ctor() {
  1184.                         this.constructor = child;
  1185.                     }
  1186.                     ctor.prototype = parent.prototype;
  1187.                     child.prototype = new ctor();
  1188.                     child.__super__ = parent.prototype;
  1189.                     return child;
  1190.                 };
  1191.                 MojioModel = _dereq_("./MojioModel");
  1192.                 module.exports = Mojio = function(_super) {
  1193.                     __extends(Mojio, _super);
  1194.                     Mojio.prototype._schema = {
  1195.                         Type: "String",
  1196.                         OwnerId: "String",
  1197.                         Name: "String",
  1198.                         Imei: "String",
  1199.                         LastContactTime: "String",
  1200.                         VehicleId: "String",
  1201.                         _id: "String",
  1202.                         _deleted: "Boolean"
  1203.                     };
  1204.                     Mojio.prototype._resource = "Mojios";
  1205.                     Mojio.prototype._model = "Mojio";
  1206.                     function Mojio(json) {
  1207.                         Mojio.__super__.constructor.call(this, json);
  1208.                     }
  1209.                     Mojio._resource = "Mojios";
  1210.                     Mojio._model = "Mojio";
  1211.                     Mojio.resource = function() {
  1212.                         return Mojio._resource;
  1213.                     };
  1214.                     Mojio.model = function() {
  1215.                         return Mojio._model;
  1216.                     };
  1217.                     return Mojio;
  1218.                 }(MojioModel);
  1219.             }).call(this);
  1220.         }, {
  1221.             "./MojioModel": 2
  1222.         } ],
  1223.         2: [ function(_dereq_, module, exports) {
  1224.             (function() {
  1225.                 var MojioModel;
  1226.                 module.exports = MojioModel = function() {
  1227.                     MojioModel._resource = "Schema";
  1228.                     MojioModel._model = "Model";
  1229.                     function MojioModel(json) {
  1230.                         this._client = null;
  1231.                         this.validate(json);
  1232.                     }
  1233.                     MojioModel.prototype.setField = function(field, value) {
  1234.                         this[field] = value;
  1235.                         return this[field];
  1236.                     };
  1237.                     MojioModel.prototype.getField = function(field) {
  1238.                         return this[field];
  1239.                     };
  1240.                     MojioModel.prototype.validate = function(json) {
  1241.                         var field, value, _results;
  1242.                         _results = [];
  1243.                         for (field in json) {
  1244.                             value = json[field];
  1245.                             _results.push(this.setField(field, value));
  1246.                         }
  1247.                         return _results;
  1248.                     };
  1249.                     MojioModel.prototype.stringify = function() {
  1250.                         return JSON.stringify(this, this.replacer);
  1251.                     };
  1252.                     MojioModel.prototype.replacer = function(key, value) {
  1253.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  1254.                             return void 0;
  1255.                         } else {
  1256.                             return value;
  1257.                         }
  1258.                     };
  1259.                     MojioModel.prototype.query = function(criteria, callback) {
  1260.                         var property, query_criteria, value;
  1261.                         if (this._client === null) {
  1262.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1263.                             return;
  1264.                         }
  1265.                         if (criteria instanceof Object) {
  1266.                             if (criteria.criteria == null) {
  1267.                                 query_criteria = "";
  1268.                                 for (property in criteria) {
  1269.                                     value = criteria[property];
  1270.                                     query_criteria += "" + property + "=" + value + ";";
  1271.                                 }
  1272.                                 criteria = {
  1273.                                     criteria: query_criteria
  1274.                                 };
  1275.                             }
  1276.                             return this._client.request({
  1277.                                 method: "GET",
  1278.                                 resource: this.resource(),
  1279.                                 parameters: criteria
  1280.                             }, function(_this) {
  1281.                                 return function(error, result) {
  1282.                                     return callback(error, _this._client.model(_this.model(), result));
  1283.                                 };
  1284.                             }(this));
  1285.                         } else if (typeof criteria === "string") {
  1286.                             return this._client.request({
  1287.                                 method: "GET",
  1288.                                 resource: this.resource(),
  1289.                                 parameters: {
  1290.                                     id: criteria
  1291.                                 }
  1292.                             }, function(_this) {
  1293.                                 return function(error, result) {
  1294.                                     return callback(error, _this._client.model(_this.model(), result));
  1295.                                 };
  1296.                             }(this));
  1297.                         } else {
  1298.                             return callback("criteria given is not in understood format, string or object.", null);
  1299.                         }
  1300.                     };
  1301.                     MojioModel.prototype.get = function(criteria, callback) {
  1302.                         return this.query(criteria, callback);
  1303.                     };
  1304.                     MojioModel.prototype.create = function(callback) {
  1305.                         if (this._client === null) {
  1306.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1307.                             return;
  1308.                         }
  1309.                         return this._client.request({
  1310.                             method: "POST",
  1311.                             resource: this.resource(),
  1312.                             body: this.stringify()
  1313.                         }, callback);
  1314.                     };
  1315.                     MojioModel.prototype.post = function(callback) {
  1316.                         return this.create(callback);
  1317.                     };
  1318.                     MojioModel.prototype.save = function(callback) {
  1319.                         if (this._client === null) {
  1320.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1321.                             return;
  1322.                         }
  1323.                         return this._client.request({
  1324.                             method: "PUT",
  1325.                             resource: this.resource(),
  1326.                             body: this.stringify(),
  1327.                             parameters: {
  1328.                                 id: this._id
  1329.                             }
  1330.                         }, callback);
  1331.                     };
  1332.                     MojioModel.prototype.put = function(callback) {
  1333.                         return this.save(callback);
  1334.                     };
  1335.                     MojioModel.prototype["delete"] = function(callback) {
  1336.                         return this._client.request({
  1337.                             method: "DELETE",
  1338.                             resource: this.resource(),
  1339.                             parameters: {
  1340.                                 id: this._id
  1341.                             }
  1342.                         }, callback);
  1343.                     };
  1344.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  1345.                         if (subject == null) {
  1346.                             subject = null;
  1347.                         }
  1348.                         return this._client.observe(object, subject, observer_callback, callback);
  1349.                     };
  1350.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  1351.                         if (subject == null) {
  1352.                             subject = null;
  1353.                         }
  1354.                         return this._client.observe(object, subject, observer_callback, callback);
  1355.                     };
  1356.                     MojioModel.prototype.store = function(model, key, value, callback) {
  1357.                         return this._client.store(model, key, value, callback);
  1358.                     };
  1359.                     MojioModel.prototype.storage = function(model, key, callback) {
  1360.                         return this._client.storage(model, key, callback);
  1361.                     };
  1362.                     MojioModel.prototype.unstore = function(model, key, callback) {
  1363.                         return this._client.unstore(model, key, callback);
  1364.                     };
  1365.                     MojioModel.prototype.statistic = function(expression, callback) {
  1366.                         return callback(null, true);
  1367.                     };
  1368.                     MojioModel.prototype.resource = function() {
  1369.                         return this._resource;
  1370.                     };
  1371.                     MojioModel.prototype.model = function() {
  1372.                         return this._model;
  1373.                     };
  1374.                     MojioModel.prototype.schema = function() {
  1375.                         return this._schema;
  1376.                     };
  1377.                     MojioModel.prototype.authorization = function(client) {
  1378.                         this._client = client;
  1379.                         return this;
  1380.                     };
  1381.                     MojioModel.prototype.id = function() {
  1382.                         return this._id;
  1383.                     };
  1384.                     MojioModel.prototype.mock = function(type, withid) {
  1385.                         var field, value, _ref;
  1386.                         if (withid == null) {
  1387.                             withid = false;
  1388.                         }
  1389.                         _ref = this.schema();
  1390.                         for (field in _ref) {
  1391.                             value = _ref[field];
  1392.                             if (field === "Type") {
  1393.                                 this.setField(field, this.model());
  1394.                             } else if (field === "UserName") {
  1395.                                 this.setField(field, "Tester");
  1396.                             } else if (field === "Email") {
  1397.                                 this.setField(field, "test@moj.io");
  1398.                             } else if (field === "Password") {
  1399.                                 this.setField(field, "Password007!");
  1400.                             } else if (field !== "_id" || withid) {
  1401.                                 switch (value) {
  1402.                                   case "Integer":
  1403.                                     this.setField(field, "0");
  1404.                                     break;
  1405.  
  1406.                                   case "Boolean":
  1407.                                     this.setField(field, false);
  1408.                                     break;
  1409.  
  1410.                                   case "String":
  1411.                                     this.setField(field, "test" + Math.random());
  1412.                                 }
  1413.                             }
  1414.                         }
  1415.                         return this;
  1416.                     };
  1417.                     return MojioModel;
  1418.                 }();
  1419.             }).call(this);
  1420.         }, {} ]
  1421.     }, {}, [ 1 ])(1);
  1422. });
  1423.  
  1424. !function(e) {
  1425.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  1426.         var f;
  1427.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  1428.         f.Observer = e();
  1429.     }
  1430. }(function() {
  1431.     var define, module, exports;
  1432.     return function e(t, n, r) {
  1433.         function s(o, u) {
  1434.             if (!n[o]) {
  1435.                 if (!t[o]) {
  1436.                     var a = typeof require == "function" && require;
  1437.                     if (!u && a) return a(o, !0);
  1438.                     if (i) return i(o, !0);
  1439.                     throw new Error("Cannot find module '" + o + "'");
  1440.                 }
  1441.                 var f = n[o] = {
  1442.                     exports: {}
  1443.                 };
  1444.                 t[o][0].call(f.exports, function(e) {
  1445.                     var n = t[o][1][e];
  1446.                     return s(n ? n : e);
  1447.                 }, f, f.exports, e, t, n, r);
  1448.             }
  1449.             return n[o].exports;
  1450.         }
  1451.         var i = typeof require == "function" && require;
  1452.         for (var o = 0; o < r.length; o++) s(r[o]);
  1453.         return s;
  1454.     }({
  1455.         1: [ function(_dereq_, module, exports) {
  1456.             (function() {
  1457.                 var MojioModel;
  1458.                 module.exports = MojioModel = function() {
  1459.                     MojioModel._resource = "Schema";
  1460.                     MojioModel._model = "Model";
  1461.                     function MojioModel(json) {
  1462.                         this._client = null;
  1463.                         this.validate(json);
  1464.                     }
  1465.                     MojioModel.prototype.setField = function(field, value) {
  1466.                         this[field] = value;
  1467.                         return this[field];
  1468.                     };
  1469.                     MojioModel.prototype.getField = function(field) {
  1470.                         return this[field];
  1471.                     };
  1472.                     MojioModel.prototype.validate = function(json) {
  1473.                         var field, value, _results;
  1474.                         _results = [];
  1475.                         for (field in json) {
  1476.                             value = json[field];
  1477.                             _results.push(this.setField(field, value));
  1478.                         }
  1479.                         return _results;
  1480.                     };
  1481.                     MojioModel.prototype.stringify = function() {
  1482.                         return JSON.stringify(this, this.replacer);
  1483.                     };
  1484.                     MojioModel.prototype.replacer = function(key, value) {
  1485.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  1486.                             return void 0;
  1487.                         } else {
  1488.                             return value;
  1489.                         }
  1490.                     };
  1491.                     MojioModel.prototype.query = function(criteria, callback) {
  1492.                         var property, query_criteria, value;
  1493.                         if (this._client === null) {
  1494.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1495.                             return;
  1496.                         }
  1497.                         if (criteria instanceof Object) {
  1498.                             if (criteria.criteria == null) {
  1499.                                 query_criteria = "";
  1500.                                 for (property in criteria) {
  1501.                                     value = criteria[property];
  1502.                                     query_criteria += "" + property + "=" + value + ";";
  1503.                                 }
  1504.                                 criteria = {
  1505.                                     criteria: query_criteria
  1506.                                 };
  1507.                             }
  1508.                             return this._client.request({
  1509.                                 method: "GET",
  1510.                                 resource: this.resource(),
  1511.                                 parameters: criteria
  1512.                             }, function(_this) {
  1513.                                 return function(error, result) {
  1514.                                     return callback(error, _this._client.model(_this.model(), result));
  1515.                                 };
  1516.                             }(this));
  1517.                         } else if (typeof criteria === "string") {
  1518.                             return this._client.request({
  1519.                                 method: "GET",
  1520.                                 resource: this.resource(),
  1521.                                 parameters: {
  1522.                                     id: criteria
  1523.                                 }
  1524.                             }, function(_this) {
  1525.                                 return function(error, result) {
  1526.                                     return callback(error, _this._client.model(_this.model(), result));
  1527.                                 };
  1528.                             }(this));
  1529.                         } else {
  1530.                             return callback("criteria given is not in understood format, string or object.", null);
  1531.                         }
  1532.                     };
  1533.                     MojioModel.prototype.get = function(criteria, callback) {
  1534.                         return this.query(criteria, callback);
  1535.                     };
  1536.                     MojioModel.prototype.create = function(callback) {
  1537.                         if (this._client === null) {
  1538.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1539.                             return;
  1540.                         }
  1541.                         return this._client.request({
  1542.                             method: "POST",
  1543.                             resource: this.resource(),
  1544.                             body: this.stringify()
  1545.                         }, callback);
  1546.                     };
  1547.                     MojioModel.prototype.post = function(callback) {
  1548.                         return this.create(callback);
  1549.                     };
  1550.                     MojioModel.prototype.save = function(callback) {
  1551.                         if (this._client === null) {
  1552.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1553.                             return;
  1554.                         }
  1555.                         return this._client.request({
  1556.                             method: "PUT",
  1557.                             resource: this.resource(),
  1558.                             body: this.stringify(),
  1559.                             parameters: {
  1560.                                 id: this._id
  1561.                             }
  1562.                         }, callback);
  1563.                     };
  1564.                     MojioModel.prototype.put = function(callback) {
  1565.                         return this.save(callback);
  1566.                     };
  1567.                     MojioModel.prototype["delete"] = function(callback) {
  1568.                         return this._client.request({
  1569.                             method: "DELETE",
  1570.                             resource: this.resource(),
  1571.                             parameters: {
  1572.                                 id: this._id
  1573.                             }
  1574.                         }, callback);
  1575.                     };
  1576.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  1577.                         if (subject == null) {
  1578.                             subject = null;
  1579.                         }
  1580.                         return this._client.observe(object, subject, observer_callback, callback);
  1581.                     };
  1582.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  1583.                         if (subject == null) {
  1584.                             subject = null;
  1585.                         }
  1586.                         return this._client.observe(object, subject, observer_callback, callback);
  1587.                     };
  1588.                     MojioModel.prototype.store = function(model, key, value, callback) {
  1589.                         return this._client.store(model, key, value, callback);
  1590.                     };
  1591.                     MojioModel.prototype.storage = function(model, key, callback) {
  1592.                         return this._client.storage(model, key, callback);
  1593.                     };
  1594.                     MojioModel.prototype.unstore = function(model, key, callback) {
  1595.                         return this._client.unstore(model, key, callback);
  1596.                     };
  1597.                     MojioModel.prototype.statistic = function(expression, callback) {
  1598.                         return callback(null, true);
  1599.                     };
  1600.                     MojioModel.prototype.resource = function() {
  1601.                         return this._resource;
  1602.                     };
  1603.                     MojioModel.prototype.model = function() {
  1604.                         return this._model;
  1605.                     };
  1606.                     MojioModel.prototype.schema = function() {
  1607.                         return this._schema;
  1608.                     };
  1609.                     MojioModel.prototype.authorization = function(client) {
  1610.                         this._client = client;
  1611.                         return this;
  1612.                     };
  1613.                     MojioModel.prototype.id = function() {
  1614.                         return this._id;
  1615.                     };
  1616.                     MojioModel.prototype.mock = function(type, withid) {
  1617.                         var field, value, _ref;
  1618.                         if (withid == null) {
  1619.                             withid = false;
  1620.                         }
  1621.                         _ref = this.schema();
  1622.                         for (field in _ref) {
  1623.                             value = _ref[field];
  1624.                             if (field === "Type") {
  1625.                                 this.setField(field, this.model());
  1626.                             } else if (field === "UserName") {
  1627.                                 this.setField(field, "Tester");
  1628.                             } else if (field === "Email") {
  1629.                                 this.setField(field, "test@moj.io");
  1630.                             } else if (field === "Password") {
  1631.                                 this.setField(field, "Password007!");
  1632.                             } else if (field !== "_id" || withid) {
  1633.                                 switch (value) {
  1634.                                   case "Integer":
  1635.                                     this.setField(field, "0");
  1636.                                     break;
  1637.  
  1638.                                   case "Boolean":
  1639.                                     this.setField(field, false);
  1640.                                     break;
  1641.  
  1642.                                   case "String":
  1643.                                     this.setField(field, "test" + Math.random());
  1644.                                 }
  1645.                             }
  1646.                         }
  1647.                         return this;
  1648.                     };
  1649.                     return MojioModel;
  1650.                 }();
  1651.             }).call(this);
  1652.         }, {} ],
  1653.         2: [ function(_dereq_, module, exports) {
  1654.             (function() {
  1655.                 var MojioModel, Observer, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  1656.                     for (var key in parent) {
  1657.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  1658.                     }
  1659.                     function ctor() {
  1660.                         this.constructor = child;
  1661.                     }
  1662.                     ctor.prototype = parent.prototype;
  1663.                     child.prototype = new ctor();
  1664.                     child.__super__ = parent.prototype;
  1665.                     return child;
  1666.                 };
  1667.                 MojioModel = _dereq_("./MojioModel");
  1668.                 module.exports = Observer = function(_super) {
  1669.                     __extends(Observer, _super);
  1670.                     Observer.prototype._schema = {
  1671.                         Type: "String",
  1672.                         Name: "String",
  1673.                         ObserverType: "String",
  1674.                         EventTypes: "Array",
  1675.                         AppId: "String",
  1676.                         OwnerId: "String",
  1677.                         Parent: "String",
  1678.                         ParentId: "String",
  1679.                         Subject: "String",
  1680.                         SubjectId: "String",
  1681.                         Transports: "Integer",
  1682.                         Status: "Integer",
  1683.                         Tokens: "Array",
  1684.                         _id: "String",
  1685.                         _deleted: "Boolean"
  1686.                     };
  1687.                     Observer.prototype._resource = "Observers";
  1688.                     Observer.prototype._model = "Observer";
  1689.                     function Observer(json) {
  1690.                         Observer.__super__.constructor.call(this, json);
  1691.                     }
  1692.                     Observer._resource = "Observers";
  1693.                     Observer._model = "Observer";
  1694.                     Observer.resource = function() {
  1695.                         return Observer._resource;
  1696.                     };
  1697.                     Observer.model = function() {
  1698.                         return Observer._model;
  1699.                     };
  1700.                     return Observer;
  1701.                 }(MojioModel);
  1702.             }).call(this);
  1703.         }, {
  1704.             "./MojioModel": 1
  1705.         } ]
  1706.     }, {}, [ 2 ])(2);
  1707. });
  1708.  
  1709. !function(e) {
  1710.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  1711.         var f;
  1712.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  1713.         f.Product = e();
  1714.     }
  1715. }(function() {
  1716.     var define, module, exports;
  1717.     return function e(t, n, r) {
  1718.         function s(o, u) {
  1719.             if (!n[o]) {
  1720.                 if (!t[o]) {
  1721.                     var a = typeof require == "function" && require;
  1722.                     if (!u && a) return a(o, !0);
  1723.                     if (i) return i(o, !0);
  1724.                     throw new Error("Cannot find module '" + o + "'");
  1725.                 }
  1726.                 var f = n[o] = {
  1727.                     exports: {}
  1728.                 };
  1729.                 t[o][0].call(f.exports, function(e) {
  1730.                     var n = t[o][1][e];
  1731.                     return s(n ? n : e);
  1732.                 }, f, f.exports, e, t, n, r);
  1733.             }
  1734.             return n[o].exports;
  1735.         }
  1736.         var i = typeof require == "function" && require;
  1737.         for (var o = 0; o < r.length; o++) s(r[o]);
  1738.         return s;
  1739.     }({
  1740.         1: [ function(_dereq_, module, exports) {
  1741.             (function() {
  1742.                 var MojioModel;
  1743.                 module.exports = MojioModel = function() {
  1744.                     MojioModel._resource = "Schema";
  1745.                     MojioModel._model = "Model";
  1746.                     function MojioModel(json) {
  1747.                         this._client = null;
  1748.                         this.validate(json);
  1749.                     }
  1750.                     MojioModel.prototype.setField = function(field, value) {
  1751.                         this[field] = value;
  1752.                         return this[field];
  1753.                     };
  1754.                     MojioModel.prototype.getField = function(field) {
  1755.                         return this[field];
  1756.                     };
  1757.                     MojioModel.prototype.validate = function(json) {
  1758.                         var field, value, _results;
  1759.                         _results = [];
  1760.                         for (field in json) {
  1761.                             value = json[field];
  1762.                             _results.push(this.setField(field, value));
  1763.                         }
  1764.                         return _results;
  1765.                     };
  1766.                     MojioModel.prototype.stringify = function() {
  1767.                         return JSON.stringify(this, this.replacer);
  1768.                     };
  1769.                     MojioModel.prototype.replacer = function(key, value) {
  1770.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  1771.                             return void 0;
  1772.                         } else {
  1773.                             return value;
  1774.                         }
  1775.                     };
  1776.                     MojioModel.prototype.query = function(criteria, callback) {
  1777.                         var property, query_criteria, value;
  1778.                         if (this._client === null) {
  1779.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1780.                             return;
  1781.                         }
  1782.                         if (criteria instanceof Object) {
  1783.                             if (criteria.criteria == null) {
  1784.                                 query_criteria = "";
  1785.                                 for (property in criteria) {
  1786.                                     value = criteria[property];
  1787.                                     query_criteria += "" + property + "=" + value + ";";
  1788.                                 }
  1789.                                 criteria = {
  1790.                                     criteria: query_criteria
  1791.                                 };
  1792.                             }
  1793.                             return this._client.request({
  1794.                                 method: "GET",
  1795.                                 resource: this.resource(),
  1796.                                 parameters: criteria
  1797.                             }, function(_this) {
  1798.                                 return function(error, result) {
  1799.                                     return callback(error, _this._client.model(_this.model(), result));
  1800.                                 };
  1801.                             }(this));
  1802.                         } else if (typeof criteria === "string") {
  1803.                             return this._client.request({
  1804.                                 method: "GET",
  1805.                                 resource: this.resource(),
  1806.                                 parameters: {
  1807.                                     id: criteria
  1808.                                 }
  1809.                             }, function(_this) {
  1810.                                 return function(error, result) {
  1811.                                     return callback(error, _this._client.model(_this.model(), result));
  1812.                                 };
  1813.                             }(this));
  1814.                         } else {
  1815.                             return callback("criteria given is not in understood format, string or object.", null);
  1816.                         }
  1817.                     };
  1818.                     MojioModel.prototype.get = function(criteria, callback) {
  1819.                         return this.query(criteria, callback);
  1820.                     };
  1821.                     MojioModel.prototype.create = function(callback) {
  1822.                         if (this._client === null) {
  1823.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1824.                             return;
  1825.                         }
  1826.                         return this._client.request({
  1827.                             method: "POST",
  1828.                             resource: this.resource(),
  1829.                             body: this.stringify()
  1830.                         }, callback);
  1831.                     };
  1832.                     MojioModel.prototype.post = function(callback) {
  1833.                         return this.create(callback);
  1834.                     };
  1835.                     MojioModel.prototype.save = function(callback) {
  1836.                         if (this._client === null) {
  1837.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  1838.                             return;
  1839.                         }
  1840.                         return this._client.request({
  1841.                             method: "PUT",
  1842.                             resource: this.resource(),
  1843.                             body: this.stringify(),
  1844.                             parameters: {
  1845.                                 id: this._id
  1846.                             }
  1847.                         }, callback);
  1848.                     };
  1849.                     MojioModel.prototype.put = function(callback) {
  1850.                         return this.save(callback);
  1851.                     };
  1852.                     MojioModel.prototype["delete"] = function(callback) {
  1853.                         return this._client.request({
  1854.                             method: "DELETE",
  1855.                             resource: this.resource(),
  1856.                             parameters: {
  1857.                                 id: this._id
  1858.                             }
  1859.                         }, callback);
  1860.                     };
  1861.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  1862.                         if (subject == null) {
  1863.                             subject = null;
  1864.                         }
  1865.                         return this._client.observe(object, subject, observer_callback, callback);
  1866.                     };
  1867.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  1868.                         if (subject == null) {
  1869.                             subject = null;
  1870.                         }
  1871.                         return this._client.observe(object, subject, observer_callback, callback);
  1872.                     };
  1873.                     MojioModel.prototype.store = function(model, key, value, callback) {
  1874.                         return this._client.store(model, key, value, callback);
  1875.                     };
  1876.                     MojioModel.prototype.storage = function(model, key, callback) {
  1877.                         return this._client.storage(model, key, callback);
  1878.                     };
  1879.                     MojioModel.prototype.unstore = function(model, key, callback) {
  1880.                         return this._client.unstore(model, key, callback);
  1881.                     };
  1882.                     MojioModel.prototype.statistic = function(expression, callback) {
  1883.                         return callback(null, true);
  1884.                     };
  1885.                     MojioModel.prototype.resource = function() {
  1886.                         return this._resource;
  1887.                     };
  1888.                     MojioModel.prototype.model = function() {
  1889.                         return this._model;
  1890.                     };
  1891.                     MojioModel.prototype.schema = function() {
  1892.                         return this._schema;
  1893.                     };
  1894.                     MojioModel.prototype.authorization = function(client) {
  1895.                         this._client = client;
  1896.                         return this;
  1897.                     };
  1898.                     MojioModel.prototype.id = function() {
  1899.                         return this._id;
  1900.                     };
  1901.                     MojioModel.prototype.mock = function(type, withid) {
  1902.                         var field, value, _ref;
  1903.                         if (withid == null) {
  1904.                             withid = false;
  1905.                         }
  1906.                         _ref = this.schema();
  1907.                         for (field in _ref) {
  1908.                             value = _ref[field];
  1909.                             if (field === "Type") {
  1910.                                 this.setField(field, this.model());
  1911.                             } else if (field === "UserName") {
  1912.                                 this.setField(field, "Tester");
  1913.                             } else if (field === "Email") {
  1914.                                 this.setField(field, "test@moj.io");
  1915.                             } else if (field === "Password") {
  1916.                                 this.setField(field, "Password007!");
  1917.                             } else if (field !== "_id" || withid) {
  1918.                                 switch (value) {
  1919.                                   case "Integer":
  1920.                                     this.setField(field, "0");
  1921.                                     break;
  1922.  
  1923.                                   case "Boolean":
  1924.                                     this.setField(field, false);
  1925.                                     break;
  1926.  
  1927.                                   case "String":
  1928.                                     this.setField(field, "test" + Math.random());
  1929.                                 }
  1930.                             }
  1931.                         }
  1932.                         return this;
  1933.                     };
  1934.                     return MojioModel;
  1935.                 }();
  1936.             }).call(this);
  1937.         }, {} ],
  1938.         2: [ function(_dereq_, module, exports) {
  1939.             (function() {
  1940.                 var MojioModel, Product, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  1941.                     for (var key in parent) {
  1942.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  1943.                     }
  1944.                     function ctor() {
  1945.                         this.constructor = child;
  1946.                     }
  1947.                     ctor.prototype = parent.prototype;
  1948.                     child.prototype = new ctor();
  1949.                     child.__super__ = parent.prototype;
  1950.                     return child;
  1951.                 };
  1952.                 MojioModel = _dereq_("./MojioModel");
  1953.                 module.exports = Product = function(_super) {
  1954.                     __extends(Product, _super);
  1955.                     Product.prototype._schema = {
  1956.                         Type: "String",
  1957.                         AppId: "String",
  1958.                         Name: "String",
  1959.                         Description: "String",
  1960.                         Shipping: "Boolean",
  1961.                         Taxable: "Boolean",
  1962.                         Price: "Float",
  1963.                         Discontinued: "Boolean",
  1964.                         OwnerId: "String",
  1965.                         CreationDate: "String",
  1966.                         _id: "String",
  1967.                         _deleted: "Boolean"
  1968.                     };
  1969.                     Product.prototype._resource = "Products";
  1970.                     Product.prototype._model = "Product";
  1971.                     function Product(json) {
  1972.                         Product.__super__.constructor.call(this, json);
  1973.                     }
  1974.                     Product._resource = "Products";
  1975.                     Product._model = "Product";
  1976.                     Product.resource = function() {
  1977.                         return Product._resource;
  1978.                     };
  1979.                     Product.model = function() {
  1980.                         return Product._model;
  1981.                     };
  1982.                     return Product;
  1983.                 }(MojioModel);
  1984.             }).call(this);
  1985.         }, {
  1986.             "./MojioModel": 1
  1987.         } ]
  1988.     }, {}, [ 2 ])(2);
  1989. });
  1990.  
  1991. !function(e) {
  1992.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  1993.         var f;
  1994.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  1995.         f.Subscription = e();
  1996.     }
  1997. }(function() {
  1998.     var define, module, exports;
  1999.     return function e(t, n, r) {
  2000.         function s(o, u) {
  2001.             if (!n[o]) {
  2002.                 if (!t[o]) {
  2003.                     var a = typeof require == "function" && require;
  2004.                     if (!u && a) return a(o, !0);
  2005.                     if (i) return i(o, !0);
  2006.                     throw new Error("Cannot find module '" + o + "'");
  2007.                 }
  2008.                 var f = n[o] = {
  2009.                     exports: {}
  2010.                 };
  2011.                 t[o][0].call(f.exports, function(e) {
  2012.                     var n = t[o][1][e];
  2013.                     return s(n ? n : e);
  2014.                 }, f, f.exports, e, t, n, r);
  2015.             }
  2016.             return n[o].exports;
  2017.         }
  2018.         var i = typeof require == "function" && require;
  2019.         for (var o = 0; o < r.length; o++) s(r[o]);
  2020.         return s;
  2021.     }({
  2022.         1: [ function(_dereq_, module, exports) {
  2023.             (function() {
  2024.                 var MojioModel;
  2025.                 module.exports = MojioModel = function() {
  2026.                     MojioModel._resource = "Schema";
  2027.                     MojioModel._model = "Model";
  2028.                     function MojioModel(json) {
  2029.                         this._client = null;
  2030.                         this.validate(json);
  2031.                     }
  2032.                     MojioModel.prototype.setField = function(field, value) {
  2033.                         this[field] = value;
  2034.                         return this[field];
  2035.                     };
  2036.                     MojioModel.prototype.getField = function(field) {
  2037.                         return this[field];
  2038.                     };
  2039.                     MojioModel.prototype.validate = function(json) {
  2040.                         var field, value, _results;
  2041.                         _results = [];
  2042.                         for (field in json) {
  2043.                             value = json[field];
  2044.                             _results.push(this.setField(field, value));
  2045.                         }
  2046.                         return _results;
  2047.                     };
  2048.                     MojioModel.prototype.stringify = function() {
  2049.                         return JSON.stringify(this, this.replacer);
  2050.                     };
  2051.                     MojioModel.prototype.replacer = function(key, value) {
  2052.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  2053.                             return void 0;
  2054.                         } else {
  2055.                             return value;
  2056.                         }
  2057.                     };
  2058.                     MojioModel.prototype.query = function(criteria, callback) {
  2059.                         var property, query_criteria, value;
  2060.                         if (this._client === null) {
  2061.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2062.                             return;
  2063.                         }
  2064.                         if (criteria instanceof Object) {
  2065.                             if (criteria.criteria == null) {
  2066.                                 query_criteria = "";
  2067.                                 for (property in criteria) {
  2068.                                     value = criteria[property];
  2069.                                     query_criteria += "" + property + "=" + value + ";";
  2070.                                 }
  2071.                                 criteria = {
  2072.                                     criteria: query_criteria
  2073.                                 };
  2074.                             }
  2075.                             return this._client.request({
  2076.                                 method: "GET",
  2077.                                 resource: this.resource(),
  2078.                                 parameters: criteria
  2079.                             }, function(_this) {
  2080.                                 return function(error, result) {
  2081.                                     return callback(error, _this._client.model(_this.model(), result));
  2082.                                 };
  2083.                             }(this));
  2084.                         } else if (typeof criteria === "string") {
  2085.                             return this._client.request({
  2086.                                 method: "GET",
  2087.                                 resource: this.resource(),
  2088.                                 parameters: {
  2089.                                     id: criteria
  2090.                                 }
  2091.                             }, function(_this) {
  2092.                                 return function(error, result) {
  2093.                                     return callback(error, _this._client.model(_this.model(), result));
  2094.                                 };
  2095.                             }(this));
  2096.                         } else {
  2097.                             return callback("criteria given is not in understood format, string or object.", null);
  2098.                         }
  2099.                     };
  2100.                     MojioModel.prototype.get = function(criteria, callback) {
  2101.                         return this.query(criteria, callback);
  2102.                     };
  2103.                     MojioModel.prototype.create = function(callback) {
  2104.                         if (this._client === null) {
  2105.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2106.                             return;
  2107.                         }
  2108.                         return this._client.request({
  2109.                             method: "POST",
  2110.                             resource: this.resource(),
  2111.                             body: this.stringify()
  2112.                         }, callback);
  2113.                     };
  2114.                     MojioModel.prototype.post = function(callback) {
  2115.                         return this.create(callback);
  2116.                     };
  2117.                     MojioModel.prototype.save = function(callback) {
  2118.                         if (this._client === null) {
  2119.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2120.                             return;
  2121.                         }
  2122.                         return this._client.request({
  2123.                             method: "PUT",
  2124.                             resource: this.resource(),
  2125.                             body: this.stringify(),
  2126.                             parameters: {
  2127.                                 id: this._id
  2128.                             }
  2129.                         }, callback);
  2130.                     };
  2131.                     MojioModel.prototype.put = function(callback) {
  2132.                         return this.save(callback);
  2133.                     };
  2134.                     MojioModel.prototype["delete"] = function(callback) {
  2135.                         return this._client.request({
  2136.                             method: "DELETE",
  2137.                             resource: this.resource(),
  2138.                             parameters: {
  2139.                                 id: this._id
  2140.                             }
  2141.                         }, callback);
  2142.                     };
  2143.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  2144.                         if (subject == null) {
  2145.                             subject = null;
  2146.                         }
  2147.                         return this._client.observe(object, subject, observer_callback, callback);
  2148.                     };
  2149.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  2150.                         if (subject == null) {
  2151.                             subject = null;
  2152.                         }
  2153.                         return this._client.observe(object, subject, observer_callback, callback);
  2154.                     };
  2155.                     MojioModel.prototype.store = function(model, key, value, callback) {
  2156.                         return this._client.store(model, key, value, callback);
  2157.                     };
  2158.                     MojioModel.prototype.storage = function(model, key, callback) {
  2159.                         return this._client.storage(model, key, callback);
  2160.                     };
  2161.                     MojioModel.prototype.unstore = function(model, key, callback) {
  2162.                         return this._client.unstore(model, key, callback);
  2163.                     };
  2164.                     MojioModel.prototype.statistic = function(expression, callback) {
  2165.                         return callback(null, true);
  2166.                     };
  2167.                     MojioModel.prototype.resource = function() {
  2168.                         return this._resource;
  2169.                     };
  2170.                     MojioModel.prototype.model = function() {
  2171.                         return this._model;
  2172.                     };
  2173.                     MojioModel.prototype.schema = function() {
  2174.                         return this._schema;
  2175.                     };
  2176.                     MojioModel.prototype.authorization = function(client) {
  2177.                         this._client = client;
  2178.                         return this;
  2179.                     };
  2180.                     MojioModel.prototype.id = function() {
  2181.                         return this._id;
  2182.                     };
  2183.                     MojioModel.prototype.mock = function(type, withid) {
  2184.                         var field, value, _ref;
  2185.                         if (withid == null) {
  2186.                             withid = false;
  2187.                         }
  2188.                         _ref = this.schema();
  2189.                         for (field in _ref) {
  2190.                             value = _ref[field];
  2191.                             if (field === "Type") {
  2192.                                 this.setField(field, this.model());
  2193.                             } else if (field === "UserName") {
  2194.                                 this.setField(field, "Tester");
  2195.                             } else if (field === "Email") {
  2196.                                 this.setField(field, "test@moj.io");
  2197.                             } else if (field === "Password") {
  2198.                                 this.setField(field, "Password007!");
  2199.                             } else if (field !== "_id" || withid) {
  2200.                                 switch (value) {
  2201.                                   case "Integer":
  2202.                                     this.setField(field, "0");
  2203.                                     break;
  2204.  
  2205.                                   case "Boolean":
  2206.                                     this.setField(field, false);
  2207.                                     break;
  2208.  
  2209.                                   case "String":
  2210.                                     this.setField(field, "test" + Math.random());
  2211.                                 }
  2212.                             }
  2213.                         }
  2214.                         return this;
  2215.                     };
  2216.                     return MojioModel;
  2217.                 }();
  2218.             }).call(this);
  2219.         }, {} ],
  2220.         2: [ function(_dereq_, module, exports) {
  2221.             (function() {
  2222.                 var MojioModel, Subscription, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  2223.                     for (var key in parent) {
  2224.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  2225.                     }
  2226.                     function ctor() {
  2227.                         this.constructor = child;
  2228.                     }
  2229.                     ctor.prototype = parent.prototype;
  2230.                     child.prototype = new ctor();
  2231.                     child.__super__ = parent.prototype;
  2232.                     return child;
  2233.                 };
  2234.                 MojioModel = _dereq_("./MojioModel");
  2235.                 module.exports = Subscription = function(_super) {
  2236.                     __extends(Subscription, _super);
  2237.                     Subscription.prototype._schema = {
  2238.                         Type: "Integer",
  2239.                         ChannelType: "Integer",
  2240.                         ChannelTarget: "String",
  2241.                         AppId: "String",
  2242.                         OwnerId: "String",
  2243.                         Event: "Integer",
  2244.                         EntityType: "Integer",
  2245.                         EntityId: "String",
  2246.                         Interval: "Integer",
  2247.                         LastMessage: "String",
  2248.                         _id: "String",
  2249.                         _deleted: "Boolean"
  2250.                     };
  2251.                     Subscription.prototype._resource = "Subscriptions";
  2252.                     Subscription.prototype._model = "Subscription";
  2253.                     function Subscription(json) {
  2254.                         Subscription.__super__.constructor.call(this, json);
  2255.                     }
  2256.                     Subscription._resource = "Subscriptions";
  2257.                     Subscription._model = "Subscription";
  2258.                     Subscription.resource = function() {
  2259.                         return Subscription._resource;
  2260.                     };
  2261.                     Subscription.model = function() {
  2262.                         return Subscription._model;
  2263.                     };
  2264.                     return Subscription;
  2265.                 }(MojioModel);
  2266.             }).call(this);
  2267.         }, {
  2268.             "./MojioModel": 1
  2269.         } ]
  2270.     }, {}, [ 2 ])(2);
  2271. });
  2272.  
  2273. !function(e) {
  2274.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  2275.         var f;
  2276.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  2277.         f.Trip = e();
  2278.     }
  2279. }(function() {
  2280.     var define, module, exports;
  2281.     return function e(t, n, r) {
  2282.         function s(o, u) {
  2283.             if (!n[o]) {
  2284.                 if (!t[o]) {
  2285.                     var a = typeof require == "function" && require;
  2286.                     if (!u && a) return a(o, !0);
  2287.                     if (i) return i(o, !0);
  2288.                     throw new Error("Cannot find module '" + o + "'");
  2289.                 }
  2290.                 var f = n[o] = {
  2291.                     exports: {}
  2292.                 };
  2293.                 t[o][0].call(f.exports, function(e) {
  2294.                     var n = t[o][1][e];
  2295.                     return s(n ? n : e);
  2296.                 }, f, f.exports, e, t, n, r);
  2297.             }
  2298.             return n[o].exports;
  2299.         }
  2300.         var i = typeof require == "function" && require;
  2301.         for (var o = 0; o < r.length; o++) s(r[o]);
  2302.         return s;
  2303.     }({
  2304.         1: [ function(_dereq_, module, exports) {
  2305.             (function() {
  2306.                 var MojioModel;
  2307.                 module.exports = MojioModel = function() {
  2308.                     MojioModel._resource = "Schema";
  2309.                     MojioModel._model = "Model";
  2310.                     function MojioModel(json) {
  2311.                         this._client = null;
  2312.                         this.validate(json);
  2313.                     }
  2314.                     MojioModel.prototype.setField = function(field, value) {
  2315.                         this[field] = value;
  2316.                         return this[field];
  2317.                     };
  2318.                     MojioModel.prototype.getField = function(field) {
  2319.                         return this[field];
  2320.                     };
  2321.                     MojioModel.prototype.validate = function(json) {
  2322.                         var field, value, _results;
  2323.                         _results = [];
  2324.                         for (field in json) {
  2325.                             value = json[field];
  2326.                             _results.push(this.setField(field, value));
  2327.                         }
  2328.                         return _results;
  2329.                     };
  2330.                     MojioModel.prototype.stringify = function() {
  2331.                         return JSON.stringify(this, this.replacer);
  2332.                     };
  2333.                     MojioModel.prototype.replacer = function(key, value) {
  2334.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  2335.                             return void 0;
  2336.                         } else {
  2337.                             return value;
  2338.                         }
  2339.                     };
  2340.                     MojioModel.prototype.query = function(criteria, callback) {
  2341.                         var property, query_criteria, value;
  2342.                         if (this._client === null) {
  2343.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2344.                             return;
  2345.                         }
  2346.                         if (criteria instanceof Object) {
  2347.                             if (criteria.criteria == null) {
  2348.                                 query_criteria = "";
  2349.                                 for (property in criteria) {
  2350.                                     value = criteria[property];
  2351.                                     query_criteria += "" + property + "=" + value + ";";
  2352.                                 }
  2353.                                 criteria = {
  2354.                                     criteria: query_criteria
  2355.                                 };
  2356.                             }
  2357.                             return this._client.request({
  2358.                                 method: "GET",
  2359.                                 resource: this.resource(),
  2360.                                 parameters: criteria
  2361.                             }, function(_this) {
  2362.                                 return function(error, result) {
  2363.                                     return callback(error, _this._client.model(_this.model(), result));
  2364.                                 };
  2365.                             }(this));
  2366.                         } else if (typeof criteria === "string") {
  2367.                             return this._client.request({
  2368.                                 method: "GET",
  2369.                                 resource: this.resource(),
  2370.                                 parameters: {
  2371.                                     id: criteria
  2372.                                 }
  2373.                             }, function(_this) {
  2374.                                 return function(error, result) {
  2375.                                     return callback(error, _this._client.model(_this.model(), result));
  2376.                                 };
  2377.                             }(this));
  2378.                         } else {
  2379.                             return callback("criteria given is not in understood format, string or object.", null);
  2380.                         }
  2381.                     };
  2382.                     MojioModel.prototype.get = function(criteria, callback) {
  2383.                         return this.query(criteria, callback);
  2384.                     };
  2385.                     MojioModel.prototype.create = function(callback) {
  2386.                         if (this._client === null) {
  2387.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2388.                             return;
  2389.                         }
  2390.                         return this._client.request({
  2391.                             method: "POST",
  2392.                             resource: this.resource(),
  2393.                             body: this.stringify()
  2394.                         }, callback);
  2395.                     };
  2396.                     MojioModel.prototype.post = function(callback) {
  2397.                         return this.create(callback);
  2398.                     };
  2399.                     MojioModel.prototype.save = function(callback) {
  2400.                         if (this._client === null) {
  2401.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2402.                             return;
  2403.                         }
  2404.                         return this._client.request({
  2405.                             method: "PUT",
  2406.                             resource: this.resource(),
  2407.                             body: this.stringify(),
  2408.                             parameters: {
  2409.                                 id: this._id
  2410.                             }
  2411.                         }, callback);
  2412.                     };
  2413.                     MojioModel.prototype.put = function(callback) {
  2414.                         return this.save(callback);
  2415.                     };
  2416.                     MojioModel.prototype["delete"] = function(callback) {
  2417.                         return this._client.request({
  2418.                             method: "DELETE",
  2419.                             resource: this.resource(),
  2420.                             parameters: {
  2421.                                 id: this._id
  2422.                             }
  2423.                         }, callback);
  2424.                     };
  2425.                     MojioModel.prototype.observe = function(object, subject, observer_callback, callback) {
  2426.                         if (subject == null) {
  2427.                             subject = null;
  2428.                         }
  2429.                         return this._client.observe(object, subject, observer_callback, callback);
  2430.                     };
  2431.                     MojioModel.prototype.unobserve = function(object, subject, observer_callback, callback) {
  2432.                         if (subject == null) {
  2433.                             subject = null;
  2434.                         }
  2435.                         return this._client.observe(object, subject, observer_callback, callback);
  2436.                     };
  2437.                     MojioModel.prototype.store = function(model, key, value, callback) {
  2438.                         return this._client.store(model, key, value, callback);
  2439.                     };
  2440.                     MojioModel.prototype.storage = function(model, key, callback) {
  2441.                         return this._client.storage(model, key, callback);
  2442.                     };
  2443.                     MojioModel.prototype.unstore = function(model, key, callback) {
  2444.                         return this._client.unstore(model, key, callback);
  2445.                     };
  2446.                     MojioModel.prototype.statistic = function(expression, callback) {
  2447.                         return callback(null, true);
  2448.                     };
  2449.                     MojioModel.prototype.resource = function() {
  2450.                         return this._resource;
  2451.                     };
  2452.                     MojioModel.prototype.model = function() {
  2453.                         return this._model;
  2454.                     };
  2455.                     MojioModel.prototype.schema = function() {
  2456.                         return this._schema;
  2457.                     };
  2458.                     MojioModel.prototype.authorization = function(client) {
  2459.                         this._client = client;
  2460.                         return this;
  2461.                     };
  2462.                     MojioModel.prototype.id = function() {
  2463.                         return this._id;
  2464.                     };
  2465.                     MojioModel.prototype.mock = function(type, withid) {
  2466.                         var field, value, _ref;
  2467.                         if (withid == null) {
  2468.                             withid = false;
  2469.                         }
  2470.                         _ref = this.schema();
  2471.                         for (field in _ref) {
  2472.                             value = _ref[field];
  2473.                             if (field === "Type") {
  2474.                                 this.setField(field, this.model());
  2475.                             } else if (field === "UserName") {
  2476.                                 this.setField(field, "Tester");
  2477.                             } else if (field === "Email") {
  2478.                                 this.setField(field, "test@moj.io");
  2479.                             } else if (field === "Password") {
  2480.                                 this.setField(field, "Password007!");
  2481.                             } else if (field !== "_id" || withid) {
  2482.                                 switch (value) {
  2483.                                   case "Integer":
  2484.                                     this.setField(field, "0");
  2485.                                     break;
  2486.  
  2487.                                   case "Boolean":
  2488.                                     this.setField(field, false);
  2489.                                     break;
  2490.  
  2491.                                   case "String":
  2492.                                     this.setField(field, "test" + Math.random());
  2493.                                 }
  2494.                             }
  2495.                         }
  2496.                         return this;
  2497.                     };
  2498.                     return MojioModel;
  2499.                 }();
  2500.             }).call(this);
  2501.         }, {} ],
  2502.         2: [ function(_dereq_, module, exports) {
  2503.             (function() {
  2504.                 var MojioModel, Trip, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
  2505.                     for (var key in parent) {
  2506.                         if (__hasProp.call(parent, key)) child[key] = parent[key];
  2507.                     }
  2508.                     function ctor() {
  2509.                         this.constructor = child;
  2510.                     }
  2511.                     ctor.prototype = parent.prototype;
  2512.                     child.prototype = new ctor();
  2513.                     child.__super__ = parent.prototype;
  2514.                     return child;
  2515.                 };
  2516.                 MojioModel = _dereq_("./MojioModel");
  2517.                 module.exports = Trip = function(_super) {
  2518.                     __extends(Trip, _super);
  2519.                     Trip.prototype._schema = {
  2520.                         Type: "String",
  2521.                         MojioId: "String",
  2522.                         VehicleId: "String",
  2523.                         StartTime: "String",
  2524.                         LastUpdatedTime: "String",
  2525.                         EndTime: "String",
  2526.                         MaxSpeed: "Float",
  2527.                         MaxAcceleration: "Float",
  2528.                         MaxDeceleration: "Float",
  2529.                         MaxRPM: "Integer",
  2530.                         FuelLevel: "Float",
  2531.                         FuelEfficiency: "Float",
  2532.                         Distance: "Float",
  2533.                         MovingTime: "Float",
  2534.                         IdleTime: "Float",
  2535.                         StopTime: "Float",
  2536.                         StartLocation: "Object",
  2537.                         LastKnownLocation: "Object",
  2538.                         EndLocation: "Object",
  2539.                         StartAddress: "Object",
  2540.                         EndAddress: "Object",
  2541.                         ForcefullyEnded: "Boolean",
  2542.                         StartMilage: "Float",
  2543.                         EndMilage: "Float",
  2544.                         _id: "String",
  2545.                         _deleted: "Boolean"
  2546.                     };
  2547.                     Trip.prototype._resource = "Trips";
  2548.                     Trip.prototype._model = "Trip";
  2549.                     function Trip(json) {
  2550.                         Trip.__super__.constructor.call(this, json);
  2551.                     }
  2552.                     Trip._resource = "Trips";
  2553.                     Trip._model = "Trip";
  2554.                     Trip.resource = function() {
  2555.                         return Trip._resource;
  2556.                     };
  2557.                     Trip.model = function() {
  2558.                         return Trip._model;
  2559.                     };
  2560.                     return Trip;
  2561.                 }(MojioModel);
  2562.             }).call(this);
  2563.         }, {
  2564.             "./MojioModel": 1
  2565.         } ]
  2566.     }, {}, [ 2 ])(2);
  2567. });
  2568.  
  2569. !function(e) {
  2570.     if ("object" == typeof exports) module.exports = e(); else if ("function" == typeof define && define.amd) define(e); else {
  2571.         var f;
  2572.         "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self),
  2573.         f.User = e();
  2574.     }
  2575. }(function() {
  2576.     var define, module, exports;
  2577.     return function e(t, n, r) {
  2578.         function s(o, u) {
  2579.             if (!n[o]) {
  2580.                 if (!t[o]) {
  2581.                     var a = typeof require == "function" && require;
  2582.                     if (!u && a) return a(o, !0);
  2583.                     if (i) return i(o, !0);
  2584.                     throw new Error("Cannot find module '" + o + "'");
  2585.                 }
  2586.                 var f = n[o] = {
  2587.                     exports: {}
  2588.                 };
  2589.                 t[o][0].call(f.exports, function(e) {
  2590.                     var n = t[o][1][e];
  2591.                     return s(n ? n : e);
  2592.                 }, f, f.exports, e, t, n, r);
  2593.             }
  2594.             return n[o].exports;
  2595.         }
  2596.         var i = typeof require == "function" && require;
  2597.         for (var o = 0; o < r.length; o++) s(r[o]);
  2598.         return s;
  2599.     }({
  2600.         1: [ function(_dereq_, module, exports) {
  2601.             (function() {
  2602.                 var MojioModel;
  2603.                 module.exports = MojioModel = function() {
  2604.                     MojioModel._resource = "Schema";
  2605.                     MojioModel._model = "Model";
  2606.                     function MojioModel(json) {
  2607.                         this._client = null;
  2608.                         this.validate(json);
  2609.                     }
  2610.                     MojioModel.prototype.setField = function(field, value) {
  2611.                         this[field] = value;
  2612.                         return this[field];
  2613.                     };
  2614.                     MojioModel.prototype.getField = function(field) {
  2615.                         return this[field];
  2616.                     };
  2617.                     MojioModel.prototype.validate = function(json) {
  2618.                         var field, value, _results;
  2619.                         _results = [];
  2620.                         for (field in json) {
  2621.                             value = json[field];
  2622.                             _results.push(this.setField(field, value));
  2623.                         }
  2624.                         return _results;
  2625.                     };
  2626.                     MojioModel.prototype.stringify = function() {
  2627.                         return JSON.stringify(this, this.replacer);
  2628.                     };
  2629.                     MojioModel.prototype.replacer = function(key, value) {
  2630.                         if (key === "_client" || key === "_schema" || key === "_resource" || key === "_model") {
  2631.                             return void 0;
  2632.                         } else {
  2633.                             return value;
  2634.                         }
  2635.                     };
  2636.                     MojioModel.prototype.query = function(criteria, callback) {
  2637.                         var property, query_criteria, value;
  2638.                         if (this._client === null) {
  2639.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2640.                             return;
  2641.                         }
  2642.                         if (criteria instanceof Object) {
  2643.                             if (criteria.criteria == null) {
  2644.                                 query_criteria = "";
  2645.                                 for (property in criteria) {
  2646.                                     value = criteria[property];
  2647.                                     query_criteria += "" + property + "=" + value + ";";
  2648.                                 }
  2649.                                 criteria = {
  2650.                                     criteria: query_criteria
  2651.                                 };
  2652.                             }
  2653.                             return this._client.request({
  2654.                                 method: "GET",
  2655.                                 resource: this.resource(),
  2656.                                 parameters: criteria
  2657.                             }, function(_this) {
  2658.                                 return function(error, result) {
  2659.                                     return callback(error, _this._client.model(_this.model(), result));
  2660.                                 };
  2661.                             }(this));
  2662.                         } else if (typeof criteria === "string") {
  2663.                             return this._client.request({
  2664.                                 method: "GET",
  2665.                                 resource: this.resource(),
  2666.                                 parameters: {
  2667.                                     id: criteria
  2668.                                 }
  2669.                             }, function(_this) {
  2670.                                 return function(error, result) {
  2671.                                     return callback(error, _this._client.model(_this.model(), result));
  2672.                                 };
  2673.                             }(this));
  2674.                         } else {
  2675.                             return callback("criteria given is not in understood format, string or object.", null);
  2676.                         }
  2677.                     };
  2678.                     MojioModel.prototype.get = function(criteria, callback) {
  2679.                         return this.query(criteria, callback);
  2680.                     };
  2681.                     MojioModel.prototype.create = function(callback) {
  2682.                         if (this._client === null) {
  2683.                             callback("No authorization set for model, use authorize(), passing in a mojio _client where login() has been called successfully.", null);
  2684.                             return;
Add Comment
Please, Sign In to add comment