error_constants[prop] = {value: errors[prop], writable: false, enumerable: true};
}
Object.defineProperties(WebAPIException, error_constants);
+Object.defineProperties(WebAPIException.prototype, error_constants);
exports.WebAPIException = WebAPIException;
exports.WebAPIError = WebAPIException;
* Represents a set of filters.
*/
exports.AttributeFilter = function(attrName, matchFlag, matchValue) {
+ if (!(this instanceof exports.AttributeFilter)) {
+ throw new WebAPIException('TypeError', 'Constructor cannot be called as function.');
+ }
var name_ = '';
var flag_ = 'EXACTLY';
var value_ = null;
flag_ = flag;
}
- if (arguments.length > 1)
- matchFlagSetter(matchFlag);
-
function matchValueSetter(value) {
value_ = value;
}
if (arguments.length > 2) {
+ matchFlagSetter(matchFlag);
matchValueSetter(matchValue);
- } else {
- matchFlagSetter('EXISTS'); // if matchValue is not used then matchFlag is set to 'EXISTS'.
+ } else if (arguments.length > 1) {
+ // if matchValue is not used then matchFlag is set to 'EXISTS'.
+ matchFlagSetter('EXISTS');
}
Object.defineProperties(this, {
* within a particular range.
*/
exports.AttributeRangeFilter = function(attrName, start, end) {
+ if (!(this instanceof exports.AttributeRangeFilter)) {
+ throw new WebAPIException('TypeError', 'Constructor cannot be called as function.');
+ }
var name_ = '';
var start_ = null;
var end_ = null;
* Represents a set of filters.
*/
exports.CompositeFilter = function(type, filters) {
+ if (!(this instanceof exports.CompositeFilter)) {
+ throw new WebAPIException('TypeError', 'Constructor cannot be called as function.');
+ }
var filterTypes = Object.keys(CompositeFilterType);
var type_ = filterTypes[0];
* SortMode is a common interface used for sorting of queried data.
*/
exports.SortMode = function(attrName, order) {
+ if (!(this instanceof exports.SortMode)) {
+ throw new WebAPIException('TypeError', 'Constructor cannot be called as function.');
+ }
var sortModeOrder = Object.keys(SortModeOrder);
var attributeName_ = '';
* Represents a point (latitude and longitude) in the map coordinate system.
*/
exports.SimpleCoordinates = function(lat, lng) {
+ if (!(this instanceof exports.SimpleCoordinates)) {
+ throw new WebAPIException('TypeError', 'Constructor cannot be called as function.');
+ }
+
var latitude = 0;
var longitude = 0;
var tmp = Number(lat);
if (!isNaN(tmp)) {
if (tmp > 90) tmp = 90;
- else if (tmp < 0) tmp = 0;
+ else if (tmp < -90) tmp = -90;
latitude = tmp;
}
var tmp = Number(lon);
if (!isNaN(tmp)) {
if (tmp > 180) tmp = 180;
- else if (tmp < 0) tmp = 0;
+ else if (tmp < -180) tmp = -180;
longitude = tmp;
}