This repository has been archived by the owner on Jul 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from JulianStier/master
Continued development
- Loading branch information
Showing
16 changed files
with
897 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["env"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,73 @@ | ||
'use strict'; | ||
|
||
const Client = require('./onfleet/client.js'); | ||
const Tasks = require('./onfleet/tasks.js'); | ||
const Workers = require('./onfleet/workers.js'); | ||
const Webhooks = require('./onfleet/webhooks.js'); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
class Onfleet { | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var Client = require('./onfleet/client.js'); | ||
var Tasks = require('./onfleet/tasks.js'); | ||
var Teams = require('./onfleet/teams.js'); | ||
var Webhooks = require('./onfleet/webhooks.js'); | ||
var Workers = require('./onfleet/workers.js'); | ||
var Destinations = require('./onfleet/destinations.js'); | ||
|
||
var Onfleet = function () { | ||
function Onfleet(apiKey, apiBase) { | ||
_classCallCheck(this, Onfleet); | ||
|
||
constructor(apiKey, apiBase) { | ||
this.client = new Client(apiKey, apiBase); | ||
this._destinations = new Destinations(this.client); | ||
this._tasks = new Tasks(this.client); | ||
this._workers = new Workers(this.client); | ||
this._teams = new Teams(this.client); | ||
this._webhooks = new Webhooks(this.client); | ||
this._workers = new Workers(this.client); | ||
} | ||
|
||
get tasks() { | ||
return this._tasks; | ||
} | ||
|
||
get workers() { | ||
return this._workers; | ||
} | ||
_createClass(Onfleet, [{ | ||
key: 'destinations', | ||
get: function get() { | ||
return this._destinations; | ||
} | ||
}, { | ||
key: 'tasks', | ||
get: function get() { | ||
return this._tasks; | ||
} | ||
}, { | ||
key: 'teams', | ||
get: function get() { | ||
return this._teams; | ||
} | ||
}, { | ||
key: 'webhooks', | ||
get: function get() { | ||
return this._webhooks; | ||
} | ||
}, { | ||
key: 'workers', | ||
get: function get() { | ||
return this._workers; | ||
} | ||
}], [{ | ||
key: 'Triggers', | ||
get: function get() { | ||
return { | ||
TASK_STARTED: 0, | ||
TASK_ETA: 1, | ||
TASK_ARRIVAL: 2, | ||
TASK_COMPLETED: 3, | ||
TASK_FAILED: 4, | ||
WORKER_DUTY: 5, | ||
TASK_CREATED: 6, | ||
TASK_UPDATED: 7, | ||
TASK_DELETED: 8, | ||
TASK_ASSIGNED: 9, | ||
TASK_UNASSIGNED: 10 | ||
}; | ||
} | ||
}]); | ||
|
||
get webhooks() { | ||
return this._webhooks; | ||
} | ||
|
||
static get Triggers() { | ||
return { | ||
TASK_STARTED: 0, | ||
TASK_ETA: 1, | ||
TASK_ARRIVAL: 2, | ||
TASK_COMPLETED: 3, | ||
TASK_FAILED: 4, | ||
WORKER_DUTY: 5, | ||
TASK_CREATED: 6, | ||
TASK_UPDATED: 7, | ||
TASK_DELETED: 8, | ||
TASK_ASSIGNED: 9, | ||
TASK_UNASSIGNED: 10 | ||
}; | ||
} | ||
} | ||
return Onfleet; | ||
}(); | ||
|
||
module.exports = Onfleet; | ||
module.exports = Onfleet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var Destinations = function () { | ||
function Destinations(client) { | ||
_classCallCheck(this, Destinations); | ||
|
||
this.client = client; | ||
} | ||
|
||
/** | ||
* Create a new destination. | ||
* | ||
* http://docs.onfleet.com/docs/destinations#create-destination | ||
* | ||
* @param {object} address - The address for the destination. | ||
* @param {array} location | ||
* @returns {Promise<object[]>} | ||
*/ | ||
|
||
|
||
_createClass(Destinations, [{ | ||
key: 'create', | ||
value: function create(address, location) { | ||
return this.client.post('/destinations', { | ||
'address': address, | ||
'location': location | ||
}); | ||
} | ||
|
||
/** | ||
* Gets a single destination. | ||
* | ||
* http://docs.onfleet.com/docs/destinations#get-single-destination | ||
* | ||
* @param {string} id | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
}, { | ||
key: 'get', | ||
value: function get(id) { | ||
if (!id) { | ||
throw new Error('No id given'); | ||
} | ||
return this.client.get('/destinations/' + id); | ||
} | ||
}]); | ||
|
||
return Destinations; | ||
}(); | ||
|
||
module.exports = Destinations; |
Oops, something went wrong.