Skip to content

Commit 9e7bc81

Browse files
committed
bump 1.2.3
1 parent 75ea4d3 commit 9e7bc81

File tree

9 files changed

+89
-17
lines changed

9 files changed

+89
-17
lines changed

dist/@fleetbase/sdk.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/@fleetbase/sdk.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cjs/fleetbase.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cjs/fleetbase.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/fleetbase.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/fleetbase.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fleetbase/sdk",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "Fleetbase JS & Node SDK",
55
"main": "dist/cjs/fleetbase.js",
66
"module": "dist/esm/fleetbase.js",

src/resources/driver.js

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,51 @@ const driverActions = new StoreActions({
2020
return this.adapter.post('drivers/verify-code', { identity, code, ...attributes }).then(this.afterFetch.bind(this));
2121
},
2222

23+
track: function (id, params = {}, options = {}) {
24+
return this.adapter.post(`drivers/${id}/track`, params, options).then(this.afterFetch.bind(this));
25+
},
26+
2327
retrieve: function (id) {
2428
return this.findRecord(id);
2529
},
30+
31+
syncDevice(token) {
32+
return this.adapter.setHeaders({ 'Driver-Token': this.token }).post('drivers/register-device', token);
33+
},
2634
});
2735

2836
class Driver extends Resource {
2937
constructor(attributes = {}, adapter, options = {}) {
30-
super(attributes, adapter, 'driver', options);
38+
super(attributes, adapter, 'driver', { actions: driverActions, ...options });
39+
}
40+
41+
/**
42+
* The latitude coordinate for the 'Place' location.
43+
*
44+
* @var {Integer}
45+
*/
46+
get latitude() {
47+
return this.getAttribute('location', new Point())?.coordinates[1];
48+
}
49+
50+
/**
51+
* The longitude coordinate for the 'Place' location.
52+
*
53+
* @var {Integer}
54+
*/
55+
get longitude() {
56+
return this.getAttribute('location', new Point())?.coordinates[0];
57+
}
58+
59+
/**
60+
* Array coordinate pair for Place location.
61+
*
62+
* @var {Array}
63+
*/
64+
get coordinates() {
65+
const { latitude, longitude } = this;
66+
67+
return [latitude, longitude];
3168
}
3269

3370
get token() {
@@ -38,13 +75,12 @@ class Driver extends Resource {
3875
return this.getAttribute('online') === true;
3976
}
4077

78+
track(params = {}, options = {}) {
79+
return this.store.track(this.id, params, options);
80+
}
81+
4182
syncDevice(token) {
42-
return this.adapter
43-
.setHeaders({ 'Driver-Token': this.token })
44-
.post('drivers/register-device', token)
45-
.then(() => {
46-
return this;
47-
});
83+
return this.store.syncDevice(token);
4884
}
4985
}
5086

src/resources/order.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Resource from '../resource';
2-
import { StoreActions } from '../utils';
2+
import { StoreActions, isResource } from '../utils';
33
import { isValid as isValidDate } from 'date-fns';
44

55
const orderActions = new StoreActions({
@@ -15,21 +15,45 @@ const orderActions = new StoreActions({
1515
return this.adapter.post(`${this.namespace}/${id}/dispatch`, params, options).then(this.afterFetch.bind(this));
1616
},
1717

18-
start: function (id,params = {}, options = {}) {
18+
start: function (id, params = {}, options = {}) {
1919
return this.adapter.post(`${this.namespace}/${id}/start`, params, options).then(this.afterFetch.bind(this));
2020
},
2121

2222
updateActivity: function (id, params = {}, options = {}) {
2323
return this.adapter.post(`${this.namespace}/${id}/update-activity`, params, options).then(this.afterFetch.bind(this));
2424
},
2525

26+
setDestination: function (id, destinationId, params = {}, options = {}) {
27+
if (isResource(destinationId)) {
28+
destinationId = destinationId.id;
29+
}
30+
31+
return this.adapter.post(`${this.namespace}/${id}/set-destination/${destinationId}`, params, options).then(this.afterFetch.bind(this));
32+
},
33+
34+
captureQrCode: function (id, subjectId = null, params = {}, options = {}) {
35+
if (isResource(subjectId)) {
36+
subjectId = subjectId.id;
37+
}
38+
39+
return this.adapter.post(`${this.namespace}/${id}/capture-qr${!subjectId ? '' : '/' + subjectId}`, params, options);
40+
},
41+
42+
captureSignature: function (id, subjectId = null, params = {}, options = {}) {
43+
if (isResource(subjectId)) {
44+
subjectId = subjectId.id;
45+
}
46+
47+
return this.adapter.post(`${this.namespace}/${id}/capture-signature${!subjectId ? '' : '/' + subjectId}`, params, options);
48+
},
49+
2650
complete: function (id, params = {}, options = {}) {
2751
return this.adapter.post(`${this.namespace}/${id}/complete`, params, options).then(this.afterFetch.bind(this));
2852
},
2953

3054
cancel: function (id, params = {}, options = {}) {
3155
return this.adapter.delete(`${this.namespace}/${id}/cancel`, params, options).then(this.afterFetch.bind(this));
32-
}
56+
},
3357
});
3458

3559
class Order extends Resource {
@@ -49,6 +73,18 @@ class Order extends Resource {
4973
return this.store.start(this.id, params, options);
5074
}
5175

76+
setDestination(destinationId, params = {}, options = {}) {
77+
return this.store.setDestination(this.id, destinationId, params, options);
78+
}
79+
80+
captureQrCode(subjectId = null, params = {}, options = {}) {
81+
return this.store.captureQrCode(this.id, subjectId, params, options);
82+
}
83+
84+
captureSignature(subjectId = null, params = {}, options = {}) {
85+
return this.store.captureSignature(this.id, subjectId, params, options);
86+
}
87+
5288
getNextActivity(params = {}, options = {}) {
5389
return this.store.getNextActivity(this.id, params, options);
5490
}

0 commit comments

Comments
 (0)