Skip to content

Commit a0a5c92

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 2594877 + 959a495 commit a0a5c92

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

libs/backendless.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,13 +2016,21 @@
20162016
}
20172017
},
20182018

2019-
addPoint : function(geopoint, async) {
2019+
savePoint : function(geopoint, async) {
20202020
if (geopoint.latitude === undefined || geopoint.longitude === undefined) {
20212021
throw 'Latitude or longitude not a number';
20222022
}
20232023
geopoint.categories = geopoint.categories || ['Default'];
20242024
geopoint.categories = Utils.isArray(geopoint.categories) ? geopoint.categories : [geopoint.categories];
20252025

2026+
var objectId = geopoint.objectId;
2027+
var method = objectId ? 'PATCH' : 'PUT',
2028+
url = this.restUrl + '/points';
2029+
2030+
if (objectId) {
2031+
url += '/' + objectId;
2032+
}
2033+
20262034
var responder = extractResponder(arguments);
20272035
var isAsync = responder != null;
20282036
var responderOverride = function(async) {
@@ -2048,13 +2056,18 @@
20482056
responder = responderOverride(responder);
20492057

20502058
return Backendless._ajax({
2051-
method : 'PUT',
2052-
url : this.restUrl + '/points',
2059+
method : method,
2060+
url : url,
20532061
data : JSON.stringify(geopoint),
20542062
isAsync : isAsync,
20552063
asyncHandler: responder
20562064
});
20572065
},
2066+
2067+
/** @deprecated */
2068+
addPoint: function(geopoint, async) {
2069+
return this.savePoint.apply(this, arguments);
2070+
},
20582071

20592072
findUtil : function(query, async) {
20602073
var url = query["url"],
@@ -4338,7 +4351,7 @@
43384351
[Backendless.Logging, ['flush']],
43394352
[Messaging.prototype, ['publish', 'sendEmail', 'cancel', 'subscribe', 'registerDevice',
43404353
'getRegistrations', 'unregisterDevice']],
4341-
[Geo.prototype, ['addPoint', 'findUtil', 'loadMetadata', 'getClusterPoints', 'addCategory',
4354+
[Geo.prototype, ['addPoint', 'savePoint', 'findUtil', 'loadMetadata', 'getClusterPoints', 'addCategory',
43424355
'getCategories', 'deleteCategory', 'deletePoint']],
43434356
[UserService.prototype, ['register', 'getUserRoles', 'roleHelper', 'login', 'describeUserClass',
43444357
'restorePassword', 'logout', 'update', 'isValidLogin', 'loginWithFacebookSdk',
@@ -4472,23 +4485,25 @@
44724485
}
44734486
};
44744487

4475-
var GeoPoint = function() {
4488+
var GeoPoint = function(args) {
4489+
args = args || {};
44764490
this.___class = "GeoPoint";
4477-
this.categories = undefined;
4478-
this.latitude = undefined;
4479-
this.longitude = undefined;
4480-
this.metadata = undefined;
4481-
this.objectId = undefined;
4491+
this.categories = args.categories;
4492+
this.latitude = args.latitude;
4493+
this.longitude = args.longitude;
4494+
this.metadata = args.metadata;
4495+
this.objectId = args.objectId;
44824496
};
44834497

4484-
var GeoCluster = function() {
4485-
this.categories = undefined;
4486-
this.latitude = undefined;
4487-
this.longitude = undefined;
4488-
this.metadata = undefined;
4489-
this.objectId = undefined;
4490-
this.totalPoints = undefined;
4491-
this.geoQuery = undefined;
4498+
var GeoCluster = function(args) {
4499+
args = args || {};
4500+
this.categories = args.categories;
4501+
this.latitude = args.latitude;
4502+
this.longitude = args.longitude;
4503+
this.metadata = args.metadata;
4504+
this.objectId = args.objectId;
4505+
this.totalPoints = args.totalPoints;
4506+
this.geoQuery = args.geoQuery;
44924507
};
44934508

44944509
var PublishOptionsHeaders = { //PublishOptions headers namespace helper

0 commit comments

Comments
 (0)