radar-sdk-js 3.0.1 → 3.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/index.js +409 -49
- package/dist/radar.js +409 -49
- package/dist/radar.min.js +1 -1
- package/package.json +1 -1
- package/src/api/matrix.js +35 -0
- package/src/api/track.js +24 -10
- package/src/api/trips.js +30 -0
- package/src/cookie.js +18 -2
- package/src/http.js +10 -0
- package/src/index.js +91 -2
- package/src/tripStatus.js +9 -0
- package/src/version.js +1 -1
package/dist/radar.js
CHANGED
|
@@ -521,6 +521,28 @@ var Radar = (function () {
|
|
|
521
521
|
}
|
|
522
522
|
};
|
|
523
523
|
|
|
524
|
+
// `ToObject` abstract operation
|
|
525
|
+
// https://tc39.github.io/ecma262/#sec-toobject
|
|
526
|
+
var toObject = function (argument) {
|
|
527
|
+
return Object(requireObjectCoercible(argument));
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
// `Object.keys` method
|
|
531
|
+
// https://tc39.github.io/ecma262/#sec-object.keys
|
|
532
|
+
var objectKeys = Object.keys || function keys(O) {
|
|
533
|
+
return objectKeysInternal(O, enumBugKeys);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
|
|
537
|
+
|
|
538
|
+
// `Object.keys` method
|
|
539
|
+
// https://tc39.github.io/ecma262/#sec-object.keys
|
|
540
|
+
_export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
|
|
541
|
+
keys: function keys(it) {
|
|
542
|
+
return objectKeys(toObject(it));
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
524
546
|
// a string of all valid unicode whitespaces
|
|
525
547
|
// eslint-disable-next-line max-len
|
|
526
548
|
var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
|
@@ -646,18 +668,61 @@ var Radar = (function () {
|
|
|
646
668
|
return Constructor;
|
|
647
669
|
}
|
|
648
670
|
|
|
671
|
+
function _defineProperty(obj, key, value) {
|
|
672
|
+
if (key in obj) {
|
|
673
|
+
Object.defineProperty(obj, key, {
|
|
674
|
+
value: value,
|
|
675
|
+
enumerable: true,
|
|
676
|
+
configurable: true,
|
|
677
|
+
writable: true
|
|
678
|
+
});
|
|
679
|
+
} else {
|
|
680
|
+
obj[key] = value;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
return obj;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
687
|
+
var keys = Object.keys(object);
|
|
688
|
+
|
|
689
|
+
if (Object.getOwnPropertySymbols) {
|
|
690
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
691
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
692
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
693
|
+
});
|
|
694
|
+
keys.push.apply(keys, symbols);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return keys;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function _objectSpread2(target) {
|
|
701
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
702
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
703
|
+
|
|
704
|
+
if (i % 2) {
|
|
705
|
+
ownKeys$1(Object(source), true).forEach(function (key) {
|
|
706
|
+
_defineProperty(target, key, source[key]);
|
|
707
|
+
});
|
|
708
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
709
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
710
|
+
} else {
|
|
711
|
+
ownKeys$1(Object(source)).forEach(function (key) {
|
|
712
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
return target;
|
|
718
|
+
}
|
|
719
|
+
|
|
649
720
|
// `IsArray` abstract operation
|
|
650
721
|
// https://tc39.github.io/ecma262/#sec-isarray
|
|
651
722
|
var isArray = Array.isArray || function isArray(arg) {
|
|
652
723
|
return classofRaw(arg) == 'Array';
|
|
653
724
|
};
|
|
654
725
|
|
|
655
|
-
// `ToObject` abstract operation
|
|
656
|
-
// https://tc39.github.io/ecma262/#sec-toobject
|
|
657
|
-
var toObject = function (argument) {
|
|
658
|
-
return Object(requireObjectCoercible(argument));
|
|
659
|
-
};
|
|
660
|
-
|
|
661
726
|
var createProperty = function (object, key, value) {
|
|
662
727
|
var propertyKey = toPrimitive(key);
|
|
663
728
|
if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
|
|
@@ -877,12 +942,6 @@ var Radar = (function () {
|
|
|
877
942
|
findIndex: createMethod$2(6)
|
|
878
943
|
};
|
|
879
944
|
|
|
880
|
-
// `Object.keys` method
|
|
881
|
-
// https://tc39.github.io/ecma262/#sec-object.keys
|
|
882
|
-
var objectKeys = Object.keys || function keys(O) {
|
|
883
|
-
return objectKeysInternal(O, enumBugKeys);
|
|
884
|
-
};
|
|
885
|
-
|
|
886
945
|
// `Object.defineProperties` method
|
|
887
946
|
// https://tc39.github.io/ecma262/#sec-object.defineproperties
|
|
888
947
|
var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
@@ -1538,7 +1597,8 @@ var Radar = (function () {
|
|
|
1538
1597
|
var date = new Date();
|
|
1539
1598
|
date.setFullYear(date.getFullYear() + 10);
|
|
1540
1599
|
var expires = "expires=".concat(date.toGMTString());
|
|
1541
|
-
|
|
1600
|
+
var sameSite = 'samesite=strict';
|
|
1601
|
+
document.cookie = "".concat(key, "=").concat(value, ";path=/;").concat(sameSite, ";").concat(expires);
|
|
1542
1602
|
} // delete cookie with {key}
|
|
1543
1603
|
|
|
1544
1604
|
}, {
|
|
@@ -1561,6 +1621,11 @@ var Radar = (function () {
|
|
|
1561
1621
|
get: function get() {
|
|
1562
1622
|
return 'radar-deviceId';
|
|
1563
1623
|
}
|
|
1624
|
+
}, {
|
|
1625
|
+
key: "DEVICE_TYPE",
|
|
1626
|
+
get: function get() {
|
|
1627
|
+
return 'radar-deviceType';
|
|
1628
|
+
}
|
|
1564
1629
|
}, {
|
|
1565
1630
|
key: "METADATA",
|
|
1566
1631
|
get: function get() {
|
|
@@ -1581,6 +1646,26 @@ var Radar = (function () {
|
|
|
1581
1646
|
get: function get() {
|
|
1582
1647
|
return 'radar-userId';
|
|
1583
1648
|
}
|
|
1649
|
+
}, {
|
|
1650
|
+
key: "INSTALL_ID",
|
|
1651
|
+
get: function get() {
|
|
1652
|
+
return 'radar-installId';
|
|
1653
|
+
}
|
|
1654
|
+
}, {
|
|
1655
|
+
key: "TRIP_OPTIONS",
|
|
1656
|
+
get: function get() {
|
|
1657
|
+
return 'radar-trip-options';
|
|
1658
|
+
}
|
|
1659
|
+
}, {
|
|
1660
|
+
key: "CUSTOM_HEADERS",
|
|
1661
|
+
get: function get() {
|
|
1662
|
+
return 'radar-custom-headers';
|
|
1663
|
+
}
|
|
1664
|
+
}, {
|
|
1665
|
+
key: "BASE_API_PATH",
|
|
1666
|
+
get: function get() {
|
|
1667
|
+
return 'radar-base-api-path';
|
|
1668
|
+
}
|
|
1584
1669
|
}]);
|
|
1585
1670
|
|
|
1586
1671
|
return Cookie;
|
|
@@ -3190,16 +3275,6 @@ var Radar = (function () {
|
|
|
3190
3275
|
}
|
|
3191
3276
|
});
|
|
3192
3277
|
|
|
3193
|
-
var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
|
|
3194
|
-
|
|
3195
|
-
// `Object.keys` method
|
|
3196
|
-
// https://tc39.github.io/ecma262/#sec-object.keys
|
|
3197
|
-
_export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
|
|
3198
|
-
keys: function keys(it) {
|
|
3199
|
-
return objectKeys(toObject(it));
|
|
3200
|
-
}
|
|
3201
|
-
});
|
|
3202
|
-
|
|
3203
3278
|
// iterable DOM collections
|
|
3204
3279
|
// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
|
|
3205
3280
|
var domIterables = {
|
|
@@ -3264,7 +3339,7 @@ var Radar = (function () {
|
|
|
3264
3339
|
return API_HOST;
|
|
3265
3340
|
}();
|
|
3266
3341
|
|
|
3267
|
-
var SDK_VERSION = '3.0.
|
|
3342
|
+
var SDK_VERSION = '3.1.0-beta.10';
|
|
3268
3343
|
|
|
3269
3344
|
var Http = /*#__PURE__*/function () {
|
|
3270
3345
|
function Http() {
|
|
@@ -3306,12 +3381,22 @@ var Radar = (function () {
|
|
|
3306
3381
|
if (!publishableKey) {
|
|
3307
3382
|
reject(STATUS.ERROR_PUBLISHABLE_KEY);
|
|
3308
3383
|
return;
|
|
3309
|
-
}
|
|
3384
|
+
} // set headers
|
|
3385
|
+
|
|
3310
3386
|
|
|
3311
3387
|
xhr.setRequestHeader('Authorization', publishableKey);
|
|
3312
3388
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
3313
3389
|
xhr.setRequestHeader('X-Radar-Device-Type', 'Web');
|
|
3314
|
-
xhr.setRequestHeader('X-Radar-SDK-Version', SDK_VERSION);
|
|
3390
|
+
xhr.setRequestHeader('X-Radar-SDK-Version', SDK_VERSION); // set custom headers if present
|
|
3391
|
+
|
|
3392
|
+
var customHeaders = Cookie.getCookie(Cookie.CUSTOM_HEADERS);
|
|
3393
|
+
|
|
3394
|
+
if (customHeaders) {
|
|
3395
|
+
var headers = JSON.parse(customHeaders);
|
|
3396
|
+
Object.keys(headers).forEach(function (header) {
|
|
3397
|
+
xhr.setRequestHeader(header, headers[header]);
|
|
3398
|
+
});
|
|
3399
|
+
}
|
|
3315
3400
|
|
|
3316
3401
|
xhr.onload = function () {
|
|
3317
3402
|
var response;
|
|
@@ -3655,6 +3740,86 @@ var Radar = (function () {
|
|
|
3655
3740
|
return Routing;
|
|
3656
3741
|
}();
|
|
3657
3742
|
|
|
3743
|
+
var Matrix = /*#__PURE__*/function () {
|
|
3744
|
+
function Matrix() {
|
|
3745
|
+
_classCallCheck(this, Matrix);
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
_createClass(Matrix, null, [{
|
|
3749
|
+
key: "getMatrixDistances",
|
|
3750
|
+
value: function () {
|
|
3751
|
+
var _getMatrixDistances = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
3752
|
+
var routingOptions,
|
|
3753
|
+
_yield$Navigator$getC,
|
|
3754
|
+
latitude,
|
|
3755
|
+
longitude,
|
|
3756
|
+
origins,
|
|
3757
|
+
destinations,
|
|
3758
|
+
mode,
|
|
3759
|
+
units,
|
|
3760
|
+
params,
|
|
3761
|
+
_args = arguments;
|
|
3762
|
+
|
|
3763
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3764
|
+
while (1) {
|
|
3765
|
+
switch (_context.prev = _context.next) {
|
|
3766
|
+
case 0:
|
|
3767
|
+
routingOptions = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
3768
|
+
|
|
3769
|
+
if (routingOptions.origins) {
|
|
3770
|
+
_context.next = 8;
|
|
3771
|
+
break;
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
_context.next = 4;
|
|
3775
|
+
return Navigator.getCurrentPosition();
|
|
3776
|
+
|
|
3777
|
+
case 4:
|
|
3778
|
+
_yield$Navigator$getC = _context.sent;
|
|
3779
|
+
latitude = _yield$Navigator$getC.latitude;
|
|
3780
|
+
longitude = _yield$Navigator$getC.longitude;
|
|
3781
|
+
routingOptions.origins = [{
|
|
3782
|
+
latitude: latitude,
|
|
3783
|
+
longitude: longitude
|
|
3784
|
+
}];
|
|
3785
|
+
|
|
3786
|
+
case 8:
|
|
3787
|
+
origins = routingOptions.origins, destinations = routingOptions.destinations, mode = routingOptions.mode, units = routingOptions.units;
|
|
3788
|
+
origins = origins || [];
|
|
3789
|
+
origins = origins.map(function (origin) {
|
|
3790
|
+
return "".concat(origin.latitude, ", ").concat(origin.longitude);
|
|
3791
|
+
}).join('|');
|
|
3792
|
+
destinations = destinations || [];
|
|
3793
|
+
destinations.map(function (destination) {
|
|
3794
|
+
return "".concat(destination.latitude, ", ").concat(destination.longitude);
|
|
3795
|
+
}).join('|');
|
|
3796
|
+
params = {
|
|
3797
|
+
origins: origins,
|
|
3798
|
+
destinations: destinations,
|
|
3799
|
+
mode: mode,
|
|
3800
|
+
units: units
|
|
3801
|
+
};
|
|
3802
|
+
return _context.abrupt("return", Http.request('GET', 'v1/route/matrix', params));
|
|
3803
|
+
|
|
3804
|
+
case 15:
|
|
3805
|
+
case "end":
|
|
3806
|
+
return _context.stop();
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
}, _callee);
|
|
3810
|
+
}));
|
|
3811
|
+
|
|
3812
|
+
function getMatrixDistances() {
|
|
3813
|
+
return _getMatrixDistances.apply(this, arguments);
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3816
|
+
return getMatrixDistances;
|
|
3817
|
+
}()
|
|
3818
|
+
}]);
|
|
3819
|
+
|
|
3820
|
+
return Matrix;
|
|
3821
|
+
}();
|
|
3822
|
+
|
|
3658
3823
|
var Search = /*#__PURE__*/function () {
|
|
3659
3824
|
function Search() {
|
|
3660
3825
|
_classCallCheck(this, Search);
|
|
@@ -4059,40 +4224,49 @@ var Radar = (function () {
|
|
|
4059
4224
|
key: "trackOnce",
|
|
4060
4225
|
value: function () {
|
|
4061
4226
|
var _trackOnce = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4062
|
-
var
|
|
4063
|
-
_location,
|
|
4227
|
+
var params,
|
|
4064
4228
|
latitude,
|
|
4065
4229
|
longitude,
|
|
4066
4230
|
accuracy,
|
|
4231
|
+
deviceLocation,
|
|
4067
4232
|
deviceId,
|
|
4068
4233
|
userId,
|
|
4234
|
+
installId,
|
|
4235
|
+
deviceType,
|
|
4069
4236
|
description,
|
|
4070
4237
|
metadata,
|
|
4238
|
+
tripOptions,
|
|
4071
4239
|
body,
|
|
4240
|
+
basePath,
|
|
4241
|
+
trackEndpoint,
|
|
4072
4242
|
response,
|
|
4073
4243
|
_args = arguments;
|
|
4074
|
-
|
|
4075
4244
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4076
4245
|
while (1) {
|
|
4077
4246
|
switch (_context.prev = _context.next) {
|
|
4078
4247
|
case 0:
|
|
4079
|
-
|
|
4248
|
+
params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
4249
|
+
latitude = params.latitude, longitude = params.longitude, accuracy = params.accuracy;
|
|
4080
4250
|
|
|
4081
|
-
if (!(!
|
|
4082
|
-
_context.next =
|
|
4251
|
+
if (!(!latitude || !longitude)) {
|
|
4252
|
+
_context.next = 9;
|
|
4083
4253
|
break;
|
|
4084
4254
|
}
|
|
4085
4255
|
|
|
4086
|
-
_context.next =
|
|
4256
|
+
_context.next = 5;
|
|
4087
4257
|
return Navigator.getCurrentPosition();
|
|
4088
4258
|
|
|
4089
|
-
case 4:
|
|
4090
|
-
location = _context.sent;
|
|
4091
|
-
|
|
4092
4259
|
case 5:
|
|
4093
|
-
|
|
4260
|
+
deviceLocation = _context.sent;
|
|
4261
|
+
latitude = deviceLocation.latitude;
|
|
4262
|
+
longitude = deviceLocation.longitude;
|
|
4263
|
+
accuracy = deviceLocation.accuracy;
|
|
4264
|
+
|
|
4265
|
+
case 9:
|
|
4094
4266
|
deviceId = Device.getId();
|
|
4095
4267
|
userId = Cookie.getCookie(Cookie.USER_ID);
|
|
4268
|
+
installId = Cookie.getCookie(Cookie.INSTALL_ID) || deviceId;
|
|
4269
|
+
deviceType = Cookie.getCookie(Cookie.DEVICE_TYPE) || 'Web';
|
|
4096
4270
|
description = Cookie.getCookie(Cookie.DESCRIPTION);
|
|
4097
4271
|
metadata = Cookie.getCookie(Cookie.METADATA);
|
|
4098
4272
|
|
|
@@ -4100,29 +4274,42 @@ var Radar = (function () {
|
|
|
4100
4274
|
metadata = JSON.parse(metadata);
|
|
4101
4275
|
}
|
|
4102
4276
|
|
|
4103
|
-
|
|
4277
|
+
tripOptions = Cookie.getCookie(Cookie.TRIP_OPTIONS);
|
|
4278
|
+
|
|
4279
|
+
if (tripOptions) {
|
|
4280
|
+
tripOptions = JSON.parse(tripOptions);
|
|
4281
|
+
}
|
|
4282
|
+
|
|
4283
|
+
body = _objectSpread2({}, params, {
|
|
4104
4284
|
accuracy: accuracy,
|
|
4105
4285
|
description: description,
|
|
4106
4286
|
deviceId: deviceId,
|
|
4107
|
-
deviceType:
|
|
4287
|
+
deviceType: deviceType,
|
|
4108
4288
|
foreground: true,
|
|
4109
|
-
installId:
|
|
4289
|
+
installId: installId,
|
|
4110
4290
|
latitude: latitude,
|
|
4111
4291
|
longitude: longitude,
|
|
4112
4292
|
metadata: metadata,
|
|
4113
4293
|
sdkVersion: SDK_VERSION,
|
|
4114
4294
|
stopped: true,
|
|
4115
|
-
userId: userId
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4295
|
+
userId: userId,
|
|
4296
|
+
tripOptions: tripOptions
|
|
4297
|
+
});
|
|
4298
|
+
basePath = Cookie.getCookie(Cookie.BASE_API_PATH) || 'v1';
|
|
4299
|
+
trackEndpoint = "".concat(basePath, "/track");
|
|
4300
|
+
_context.next = 23;
|
|
4301
|
+
return Http.request('POST', trackEndpoint, body);
|
|
4302
|
+
|
|
4303
|
+
case 23:
|
|
4121
4304
|
response = _context.sent;
|
|
4122
|
-
response.location =
|
|
4305
|
+
response.location = {
|
|
4306
|
+
latitude: latitude,
|
|
4307
|
+
longitude: longitude,
|
|
4308
|
+
accuracy: accuracy
|
|
4309
|
+
};
|
|
4123
4310
|
return _context.abrupt("return", response);
|
|
4124
4311
|
|
|
4125
|
-
case
|
|
4312
|
+
case 26:
|
|
4126
4313
|
case "end":
|
|
4127
4314
|
return _context.stop();
|
|
4128
4315
|
}
|
|
@@ -4141,6 +4328,72 @@ var Radar = (function () {
|
|
|
4141
4328
|
return Track;
|
|
4142
4329
|
}();
|
|
4143
4330
|
|
|
4331
|
+
var Trips = /*#__PURE__*/function () {
|
|
4332
|
+
function Trips() {
|
|
4333
|
+
_classCallCheck(this, Trips);
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
_createClass(Trips, null, [{
|
|
4337
|
+
key: "updateTrip",
|
|
4338
|
+
value: function () {
|
|
4339
|
+
var _updateTrip = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4340
|
+
var tripOptions,
|
|
4341
|
+
status,
|
|
4342
|
+
externalId,
|
|
4343
|
+
destinationGeofenceTag,
|
|
4344
|
+
destinationGeofenceExternalId,
|
|
4345
|
+
mode,
|
|
4346
|
+
metadata,
|
|
4347
|
+
params,
|
|
4348
|
+
basePath,
|
|
4349
|
+
_args = arguments;
|
|
4350
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4351
|
+
while (1) {
|
|
4352
|
+
switch (_context.prev = _context.next) {
|
|
4353
|
+
case 0:
|
|
4354
|
+
tripOptions = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
4355
|
+
status = _args.length > 1 ? _args[1] : undefined;
|
|
4356
|
+
externalId = tripOptions.externalId, destinationGeofenceTag = tripOptions.destinationGeofenceTag, destinationGeofenceExternalId = tripOptions.destinationGeofenceExternalId, mode = tripOptions.mode, metadata = tripOptions.metadata;
|
|
4357
|
+
params = {
|
|
4358
|
+
externalId: externalId,
|
|
4359
|
+
status: status,
|
|
4360
|
+
destinationGeofenceTag: destinationGeofenceTag,
|
|
4361
|
+
destinationGeofenceExternalId: destinationGeofenceExternalId,
|
|
4362
|
+
mode: mode,
|
|
4363
|
+
metadata: metadata
|
|
4364
|
+
};
|
|
4365
|
+
basePath = Cookie.getCookie(Cookie.BASE_API_PATH) || 'v1';
|
|
4366
|
+
return _context.abrupt("return", Http.request('PATCH', "".concat(basePath, "/trips/").concat(externalId), params));
|
|
4367
|
+
|
|
4368
|
+
case 6:
|
|
4369
|
+
case "end":
|
|
4370
|
+
return _context.stop();
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
}, _callee);
|
|
4374
|
+
}));
|
|
4375
|
+
|
|
4376
|
+
function updateTrip() {
|
|
4377
|
+
return _updateTrip.apply(this, arguments);
|
|
4378
|
+
}
|
|
4379
|
+
|
|
4380
|
+
return updateTrip;
|
|
4381
|
+
}()
|
|
4382
|
+
}]);
|
|
4383
|
+
|
|
4384
|
+
return Trips;
|
|
4385
|
+
}();
|
|
4386
|
+
|
|
4387
|
+
var TRIP_STATUS = {
|
|
4388
|
+
STARTED: "started",
|
|
4389
|
+
APPROACHING: "approaching",
|
|
4390
|
+
ARRIVED: "arrived",
|
|
4391
|
+
COMPLETED: "completed",
|
|
4392
|
+
EXPIRED: "expired",
|
|
4393
|
+
CANCELED: "canceled",
|
|
4394
|
+
UNKNOWN: undefined
|
|
4395
|
+
};
|
|
4396
|
+
|
|
4144
4397
|
var defaultCallback = function defaultCallback() {};
|
|
4145
4398
|
|
|
4146
4399
|
var handleError = function handleError(callback) {
|
|
@@ -4178,8 +4431,9 @@ var Radar = (function () {
|
|
|
4178
4431
|
}
|
|
4179
4432
|
}, {
|
|
4180
4433
|
key: "setHost",
|
|
4181
|
-
value: function setHost(host) {
|
|
4434
|
+
value: function setHost(host, baseApiPath) {
|
|
4182
4435
|
Cookie.setCookie(Cookie.HOST, host, true);
|
|
4436
|
+
Cookie.setCookie(Cookie.BASE_API_PATH, baseApiPath);
|
|
4183
4437
|
}
|
|
4184
4438
|
}, {
|
|
4185
4439
|
key: "setUserId",
|
|
@@ -4191,6 +4445,21 @@ var Radar = (function () {
|
|
|
4191
4445
|
|
|
4192
4446
|
Cookie.setCookie(Cookie.USER_ID, String(userId).trim());
|
|
4193
4447
|
}
|
|
4448
|
+
}, {
|
|
4449
|
+
key: "setDeviceId",
|
|
4450
|
+
value: function setDeviceId(deviceId, installId) {
|
|
4451
|
+
if (deviceId) {
|
|
4452
|
+
Cookie.setCookie(Cookie.DEVICE_ID, String(deviceId).trim());
|
|
4453
|
+
} else {
|
|
4454
|
+
Cookie.deleteCookie(Cookie.DEVICE_ID);
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
if (installId) {
|
|
4458
|
+
Cookie.setCookie(Cookie.INSTALL_ID, String(installId).trim());
|
|
4459
|
+
} else {
|
|
4460
|
+
Cookie.deleteCookie(Cookie.INSTALL_ID);
|
|
4461
|
+
}
|
|
4462
|
+
}
|
|
4194
4463
|
}, {
|
|
4195
4464
|
key: "setDescription",
|
|
4196
4465
|
value: function setDescription(description) {
|
|
@@ -4211,6 +4480,18 @@ var Radar = (function () {
|
|
|
4211
4480
|
|
|
4212
4481
|
Cookie.setCookie(Cookie.METADATA, JSON.stringify(metadata));
|
|
4213
4482
|
}
|
|
4483
|
+
}, {
|
|
4484
|
+
key: "setRequestHeaders",
|
|
4485
|
+
value: function setRequestHeaders() {
|
|
4486
|
+
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4487
|
+
|
|
4488
|
+
if (!Object.keys(headers).length) {
|
|
4489
|
+
Cookie.deleteCookie(Cookie.CUSTOM_HEADERS);
|
|
4490
|
+
return;
|
|
4491
|
+
}
|
|
4492
|
+
|
|
4493
|
+
Cookie.setCookie(Cookie.CUSTOM_HEADERS, JSON.stringify(headers));
|
|
4494
|
+
}
|
|
4214
4495
|
}, {
|
|
4215
4496
|
key: "getLocation",
|
|
4216
4497
|
value: function getLocation() {
|
|
@@ -4266,6 +4547,74 @@ var Radar = (function () {
|
|
|
4266
4547
|
}, response);
|
|
4267
4548
|
}).catch(handleError(callback));
|
|
4268
4549
|
}
|
|
4550
|
+
}, {
|
|
4551
|
+
key: "startTrip",
|
|
4552
|
+
value: function startTrip(tripOptions) {
|
|
4553
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCallback;
|
|
4554
|
+
Trips.updateTrip(tripOptions, TRIP_STATUS.STARTED).then(function (response) {
|
|
4555
|
+
Cookie.setCookie(Cookie.TRIP_OPTIONS, JSON.stringify(tripOptions));
|
|
4556
|
+
callback(null, {
|
|
4557
|
+
trip: response.trip,
|
|
4558
|
+
events: response.events,
|
|
4559
|
+
status: STATUS.SUCCESS
|
|
4560
|
+
}, response);
|
|
4561
|
+
}).catch(handleError(callback));
|
|
4562
|
+
}
|
|
4563
|
+
}, {
|
|
4564
|
+
key: "updateTrip",
|
|
4565
|
+
value: function updateTrip(tripOptions, status) {
|
|
4566
|
+
var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultCallback;
|
|
4567
|
+
Trips.updateTrip(tripOptions, status).then(function (response) {
|
|
4568
|
+
// set cookie
|
|
4569
|
+
Cookie.setCookie(Cookie.TRIP_OPTIONS, JSON.stringify(tripOptions));
|
|
4570
|
+
callback(null, {
|
|
4571
|
+
trip: response.trip,
|
|
4572
|
+
events: response.events,
|
|
4573
|
+
status: STATUS.SUCCESS
|
|
4574
|
+
}, response);
|
|
4575
|
+
}).catch(handleError(callback));
|
|
4576
|
+
}
|
|
4577
|
+
}, {
|
|
4578
|
+
key: "completeTrip",
|
|
4579
|
+
value: function completeTrip() {
|
|
4580
|
+
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultCallback;
|
|
4581
|
+
var tripOptions = Radar.getTripOptions();
|
|
4582
|
+
Trips.updateTrip(tripOptions, TRIP_STATUS.COMPLETED).then(function (response) {
|
|
4583
|
+
// clear tripOptions
|
|
4584
|
+
Cookie.deleteCookie(Cookie.TRIP_OPTIONS);
|
|
4585
|
+
callback(null, {
|
|
4586
|
+
trip: response.trip,
|
|
4587
|
+
events: response.events,
|
|
4588
|
+
status: STATUS.SUCCESS
|
|
4589
|
+
}, response);
|
|
4590
|
+
}).catch(handleError(callback));
|
|
4591
|
+
}
|
|
4592
|
+
}, {
|
|
4593
|
+
key: "cancelTrip",
|
|
4594
|
+
value: function cancelTrip() {
|
|
4595
|
+
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultCallback;
|
|
4596
|
+
var tripOptions = Radar.getTripOptions();
|
|
4597
|
+
Trips.updateTrip(tripOptions, TRIP_STATUS.CANCELED).then(function (response) {
|
|
4598
|
+
// clear tripOptions
|
|
4599
|
+
Cookie.deleteCookie(Cookie.TRIP_OPTIONS);
|
|
4600
|
+
callback(null, {
|
|
4601
|
+
trip: response.trip,
|
|
4602
|
+
events: response.events,
|
|
4603
|
+
status: STATUS.SUCCESS
|
|
4604
|
+
}, response);
|
|
4605
|
+
}).catch(handleError(callback));
|
|
4606
|
+
}
|
|
4607
|
+
}, {
|
|
4608
|
+
key: "getTripOptions",
|
|
4609
|
+
value: function getTripOptions() {
|
|
4610
|
+
var tripOptions = Cookie.getCookie(Cookie.TRIP_OPTIONS);
|
|
4611
|
+
|
|
4612
|
+
if (tripOptions) {
|
|
4613
|
+
tripOptions = JSON.parse(tripOptions);
|
|
4614
|
+
}
|
|
4615
|
+
|
|
4616
|
+
return tripOptions;
|
|
4617
|
+
}
|
|
4269
4618
|
}, {
|
|
4270
4619
|
key: "searchPlaces",
|
|
4271
4620
|
value: function searchPlaces(searchOptions) {
|
|
@@ -4363,6 +4712,17 @@ var Radar = (function () {
|
|
|
4363
4712
|
}, response);
|
|
4364
4713
|
}).catch(handleError(callback));
|
|
4365
4714
|
}
|
|
4715
|
+
}, {
|
|
4716
|
+
key: "getMatrix",
|
|
4717
|
+
value: function getMatrix(routingOptions) {
|
|
4718
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCallback;
|
|
4719
|
+
Matrix.getMatrixDistances(routingOptions).then(function (response) {
|
|
4720
|
+
callback(null, {
|
|
4721
|
+
routes: response.routes,
|
|
4722
|
+
status: STATUS.SUCCESS
|
|
4723
|
+
}, response);
|
|
4724
|
+
}).catch(handleError(callback));
|
|
4725
|
+
}
|
|
4366
4726
|
}, {
|
|
4367
4727
|
key: "VERSION",
|
|
4368
4728
|
get: function get() {
|