Skip to content

Commit

Permalink
update package version
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Aug 3, 2021
1 parent 1c6ebd2 commit de8e39a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 20
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
3 changes: 2 additions & 1 deletion src/fleetbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BrowserAdapter, NodeAdapter, EmberJsAdapter, Adapter } from './adapters
import { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, isResource, GoogleAddress, Collection, StoreActions } from './utils';
import { pluralize, singularize, classify, dasherize, camelize } from './utils/string';
import { extendStoreActions } from './store';
import { orderActions } from './resources/order';

/**
* // instance
Expand Down Expand Up @@ -57,7 +58,7 @@ export default class Fleetbase {

this.adapter = config.adapter || detectAdapter(this.options);

this.orders = new Store('order', this.adapter);
this.orders = new Store('order', this.adapter).extendActions(orderActions);
this.entities = new Store('entity', this.adapter);
this.places = new Store('place', this.adapter);
this.drivers = new Store('driver', this.adapter);
Expand Down
24 changes: 23 additions & 1 deletion src/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,24 @@ class Resource {
return this.update(dirtyAttributes);
}

/**
* Returns the date instance resource was created.
*
* @return {Date}
*/
get createdAt() {
return this.hasAttribute('created_at') ? new Date(this.getAttribute('created_at')) : null;
}

/**
* Returns the date instance resource was created.
*
* @return {Date}
*/
get updatedAt() {
return this.hasAttribute('updated_at') ? new Date(this.getAttribute('updated_at')) : null;
}

/**
* Checks if resource is loaded from the server.
*
Expand Down Expand Up @@ -371,10 +389,14 @@ class Resource {
*/
hasAttribute(property) {
if (isArray(property)) {
const attributeKeys = Object.keys(this.attributes);
const attributeKeys = Object.keys(this.attributes || {});
return property.every((prop) => attributeKeys.includes(prop));
}

if (!this.attributes) {
return false;
}

return property in this.attributes;
}

Expand Down
15 changes: 14 additions & 1 deletion src/resources/order.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import Resource from '../resource';
import { StoreActions } from '../utils';

const orderActions = new StoreActions({
getDistanceAndTime: function (id, options = {}) {
return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, {}, options);
},
});

class Order extends Resource {
constructor(attributes = {}, adapter, options = {}) {
super(attributes, adapter, 'order', options);
super(attributes, adapter, 'order', { actions: orderActions, ...options });
}

getDistanceAndTime() {
return this.store.getDistanceAndTime(this.id);
}
}

export default Order;

export { orderActions };

0 comments on commit de8e39a

Please sign in to comment.