npm install https://github.com/CityPantry/onfleet.js/tarball/v3.0.0
var Onfleet = require('onfleet');
var onfleet = new Onfleet('<your api key>', 'https://onfleet.com/api/v2')
Get worker by id:
onfleet.workers.get('<worker id>')
.then(worker => {...})
.catch(...);
Get all workers:
onfleet.workers.all()
.then(workers => {...})
.catch(...);
Get task by id:
onfleet.tasks.get('<task id>')
.then(task => {...})
.catch(...);
Get all tasks: Note: lastId is used for pagination. It is null when the last page of data has been fetched
onfleet.tasks.all(from, to=null, lastId=null)
.then(result => {
var lastId = result.lastId;
var tasks = result.tasks;
...
})
.catch(...);
Get task by short id:
onfleet.workers.byShortId('<task short id>')
.then(task => {...})
.catch(...);
Get all tasks on certain day:
onfleet.workers.onDay(moment())
.then(tasks => {...})
.catch(...);
Get all today's tasks:
onfleet.workers.today()
.then(tasks => {...})
.catch(...);
Get all webhooks:
onfleet.webhooks.all()
.then(tasks => {...})
.catch(...);
Create webhook:
onfleet.webhooks.create('<webhook url>', triggerId, threshold=null)
.then(() => {...})
.catch(...);
Delete webhook:
onfleet.webhooks.delete('<webhook id>')
.then(() => {...})
.catch(...);