A javascript wrapper for the HyperTrack api.
npm install hypertrack
You'll need your hypertrack secret key. You can find this from your account page. To start using, you can do the following:
var hypertrack = require('hypertrack')('<YOUR HYPERTRACK SECRET KEY>');
// hypertrack.{ RESOURCE_NAME }.{ METHOD_NAME }
Every resource method accepts an optional callback as the last argument:
hypertrack.users.create(
{ name: 'Tapan Pandita', phone: '+16502469293' },
function(err, user) {
err; // null if no error occurred
user; // the created user object
}
);
Additionally, every resource method returns a promise, so you don't have to use the regular callback. E.g.
// Create a new customer and then a new destination for that customer:
hypertrack.users.create({
name: 'Tapan Pandita',
phone: '+16502469293'
}).then(function(user) {
hypertrack.users.assign_actions(user.id, {"action_ids": ["123e4567-e89b-12d3-a456-426655440000"]})
}).catch(function(err) {
// Deal with an error
});
For detailed documentation of the methods available, please visit the official HyperTrack API documentation.
Run the tests using npm
:
$ npm install
$ npm test