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.customers.create(
{ name: 'Tapan Pandita', email: '[email protected]' },
function(err, customer) {
err; // null if no error occurred
customer; // the created customer 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.customers.create({
name: 'Tapan Pandita',
email: '[email protected]'
}).then(function(customer) {
return hypertrack.destination.create({
customer_id: customer.id,
address: '270 Linden Street',
city: 'San Francisco',
country: 'US'
});
}).then(function(destination) {
console.log(destination);
}).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