Skip to content

Commit

Permalink
bump 1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Feb 24, 2022
1 parent 75ea4d3 commit 9e7bc81
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 17 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.2",
"version": "1.2.3",
"description": "Fleetbase JS & Node SDK",
"main": "dist/cjs/fleetbase.js",
"module": "dist/esm/fleetbase.js",
Expand Down
50 changes: 43 additions & 7 deletions src/resources/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,51 @@ const driverActions = new StoreActions({
return this.adapter.post('drivers/verify-code', { identity, code, ...attributes }).then(this.afterFetch.bind(this));
},

track: function (id, params = {}, options = {}) {
return this.adapter.post(`drivers/${id}/track`, params, options).then(this.afterFetch.bind(this));
},

retrieve: function (id) {
return this.findRecord(id);
},

syncDevice(token) {
return this.adapter.setHeaders({ 'Driver-Token': this.token }).post('drivers/register-device', token);
},
});

class Driver extends Resource {
constructor(attributes = {}, adapter, options = {}) {
super(attributes, adapter, 'driver', options);
super(attributes, adapter, 'driver', { actions: driverActions, ...options });
}

/**
* The latitude coordinate for the 'Place' location.
*
* @var {Integer}
*/
get latitude() {
return this.getAttribute('location', new Point())?.coordinates[1];
}

/**
* The longitude coordinate for the 'Place' location.
*
* @var {Integer}
*/
get longitude() {
return this.getAttribute('location', new Point())?.coordinates[0];
}

/**
* Array coordinate pair for Place location.
*
* @var {Array}
*/
get coordinates() {
const { latitude, longitude } = this;

return [latitude, longitude];
}

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

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

syncDevice(token) {
return this.adapter
.setHeaders({ 'Driver-Token': this.token })
.post('drivers/register-device', token)
.then(() => {
return this;
});
return this.store.syncDevice(token);
}
}

Expand Down
42 changes: 39 additions & 3 deletions src/resources/order.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Resource from '../resource';
import { StoreActions } from '../utils';
import { StoreActions, isResource } from '../utils';
import { isValid as isValidDate } from 'date-fns';

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

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

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

setDestination: function (id, destinationId, params = {}, options = {}) {
if (isResource(destinationId)) {
destinationId = destinationId.id;
}

return this.adapter.post(`${this.namespace}/${id}/set-destination/${destinationId}`, params, options).then(this.afterFetch.bind(this));
},

captureQrCode: function (id, subjectId = null, params = {}, options = {}) {
if (isResource(subjectId)) {
subjectId = subjectId.id;
}

return this.adapter.post(`${this.namespace}/${id}/capture-qr${!subjectId ? '' : '/' + subjectId}`, params, options);
},

captureSignature: function (id, subjectId = null, params = {}, options = {}) {
if (isResource(subjectId)) {
subjectId = subjectId.id;
}

return this.adapter.post(`${this.namespace}/${id}/capture-signature${!subjectId ? '' : '/' + subjectId}`, params, options);
},

complete: function (id, params = {}, options = {}) {
return this.adapter.post(`${this.namespace}/${id}/complete`, params, options).then(this.afterFetch.bind(this));
},

cancel: function (id, params = {}, options = {}) {
return this.adapter.delete(`${this.namespace}/${id}/cancel`, params, options).then(this.afterFetch.bind(this));
}
},
});

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

setDestination(destinationId, params = {}, options = {}) {
return this.store.setDestination(this.id, destinationId, params, options);
}

captureQrCode(subjectId = null, params = {}, options = {}) {
return this.store.captureQrCode(this.id, subjectId, params, options);
}

captureSignature(subjectId = null, params = {}, options = {}) {
return this.store.captureSignature(this.id, subjectId, params, options);
}

getNextActivity(params = {}, options = {}) {
return this.store.getNextActivity(this.id, params, options);
}
Expand Down

0 comments on commit 9e7bc81

Please sign in to comment.