Skip to content

Commit

Permalink
added isOnline and token getter for driver resource, patched syncDevi…
Browse files Browse the repository at this point in the history
…ce method, bump v1.2.5
  • Loading branch information
roncodes committed Feb 28, 2022
1 parent 74290fe commit adb8c0b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/@fleetbase/sdk.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/@fleetbase/sdk.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/fleetbase.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/fleetbase.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/fleetbase.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/fleetbase.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/sdk",
"version": "1.2.4",
"version": "1.2.5",
"description": "Fleetbase JS & Node SDK",
"main": "dist/cjs/fleetbase.js",
"module": "dist/esm/fleetbase.js",
Expand Down
16 changes: 12 additions & 4 deletions src/resources/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const driverActions = new StoreActions({
return this.findRecord(id);
},

syncDevice(token) {
return this.adapter.setHeaders({ 'Driver-Token': this.token }).post('drivers/register-device', token);
syncDevice(id, params = {}, options = {}) {
return this.adapter.post(`drivers/${id}/register-device`, params, options);
},
});

Expand All @@ -38,6 +38,14 @@ class Driver extends Resource {
super(attributes, adapter, 'driver', { actions: driverActions, ...options });
}

get token() {
return this.getAttribute('token');
}

get isOnline() {
return this.getAttribute('online') === true;
}

/**
* The latitude coordinate for the 'Place' location.
*
Expand Down Expand Up @@ -79,8 +87,8 @@ class Driver extends Resource {
return this.store.track(this.id, params, options);
}

syncDevice(token) {
return this.store.syncDevice(token);
syncDevice(params = {}, options = {}) {
return this.store.syncDevice(this.id, params, options);
}
}

Expand Down

0 comments on commit adb8c0b

Please sign in to comment.