Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 dist/fleetbase.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/fleetbase.min.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.13",
"version": "1.2.14",
"description": "Fleetbase JS & Node SDK",
"repository": "https://github.com/fleetbase/fleetbase-js",
"license": "AGPL-3.0-or-later",
Expand Down
1 change: 1 addition & 0 deletions src/fleetbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default class Fleetbase {
this.vendors = new Store('vendor', this.adapter);
this.contacts = new Store('contact', this.adapter);
this.serviceAreas = new Store('service-area', this.adapter);
this.serviceQuotes = new Store('service-quote', this.adapter);
this.zones = new Store('zone', this.adapter);
this.fleets = new Store('fleet', this.adapter);
this.organizations = new Store('organization', this.adapter).extendActions(organizationActions);
Expand Down
24 changes: 22 additions & 2 deletions src/resources/service-quote.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import Resource from '../resource.js';
import { register } from '../registry.js';
import { isResource } from '../resource.js';
import StoreActions from '../utils/store-actions.js';

export const serviceQuoteActions = new StoreActions({
fromPayload(payload, params = {}) {
if (isResource(payload)) {
payload = payload.id;
}

return this.adapter.get(`${this.namespace}`, { payload, ...params }).then(this.afterFetch.bind(this));
},

fromPreliminary(params = {}) {
return this.adapter.get(`${this.namespace}/preliminary`, { ...params }).then(this.afterFetch.bind(this));
},
});

export default class ServiceQuote extends Resource {
constructor(attributes = {}, adapter, options = {}) {
super(attributes, adapter, 'service-quote', options);
}

fromPreliminary() {}
fromPreliminary(params = {}) {
return this.store.fromPreliminary(params);
}

fromPayload() {}
fromPayload(payload, params = {}) {
return this.store.fromPayload(payload, params);
}
}

register('resource', 'ServiceQuote', ServiceQuote);
39 changes: 39 additions & 0 deletions src/resources/vehicle.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,49 @@
import Resource from '../resource.js';
import { register } from '../registry.js';
import { Point } from '@fleetbase/sdk';

export default class Vehicle extends Resource {
constructor(attributes = {}, adapter, options = {}) {
super(attributes, adapter, 'vehicle', options);
}

/**
* Attribute which determines if vehicle is online.
*
* @var {Integer}
*/
get isOnline() {
return this.getAttribute('online') === true;
}

/**
* 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];
}
}

register('resource', 'Vehicle', Vehicle);
Loading