/**
* Copyright© 2016, Oracle and/or its affiliates. All rights reserved.
*/
/**
* Class that represents an object returned by a custom code API.
* @constructor
* @global
*/
function MobileObject(endpoint, uri) {
MobileResource.call(this, endpoint, uri);
// TODO: check if we need the property
this._type = SyncResourceType.item;
}
MobileObject.prototype = Object.create(MobileResource.prototype);
MobileObject.prototype.constructor = MobileObject;
/**
* Saves any changes to the object back to the service.
* @param saveIfOffline {Boolean} If true will cache updates locally and sync them back to the service if the device is offline; if false will fail if the device is offline.
* @return {Promise.<MobileObject|NetworkResponse>}
*/
// TODO: review this method, the method should be private
// TODO: This method is misleading, this method shows that the mobile object can exists without collection.
// TODO: We should move the functionality to collection object, to method add
MobileObject.prototype.save = function(saveIfOffline) {
return this._getEndpoint()._save(this, saveIfOffline);
};
/**
* Saves any changes to the object back to the service.
* @param deleteIfOffline {Boolean} If true will cache the delete locally and sync back to the service if the device is offline; if false will fail if the device is offline.
* @return {Promise.<Undefined|NetworkResponse>}
*/
// TODO: review this method, the method should be private
// TODO: This method is misleading, this method shows that the mobile object can exists without collection. Better approach is provide collection functionality to add objects to server.
// TODO: We should move the functionality to collection object, to method remove
MobileObject.prototype.delete = function(deleteIfOffline) {
return this._getEndpoint()._delete(this, deleteIfOffline);
};