Skip to content

matmar10/hypertrack-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HyperTrack Node Bindings

Build Status Coverage Status npm version Slack Status

A javascript wrapper for the HyperTrack api.

Installation

npm install hypertrack

Usage

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
});

Documentation

For detailed documentation of the methods available, please visit the official HyperTrack API documentation.

Testing

Run the tests using npm:

$ npm install
$ npm test

About

HyperTrack node.js bindings

Resources

License

Stars

Watchers

Forks

Packages

No packages published