Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

JustEatForBusiness/onfleet.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Onfleet API for Node.js

Getting Started

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')

Documentation

Workers

Get worker by id:

onfleet.workers.get('<worker id>')
    .then(worker => {...})
    .catch(...);

Get all workers:

onfleet.workers.all()
    .then(workers => {...})
    .catch(...);

Tasks

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(...);

Webhooks

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(...);

Onfleet API docs

http://docs.onfleet.com/v2.0/docs/introduction