Node library for Lightspeed API
- Auto Rate Limiting
- ES6 as a source.
- Exports in a umd format so your library works everywhere.
- ES6 test setup with Mocha and Chai. - Not thoroughly tested yet
- Linting with ESLint.
Have in mind that you have to build your library before publishing. The files under the lib folder are the ones that should be distributed.
-
Define your auth config
let lib = new LightspeedApi({ clientId: 'yourID', clientSecret: 'yourSecret', refreshToken: 'yourRefreshToken', accountId: 'yourAccountID' }); -
Call a resource
let item = lib.resource('item'); <!-- Returns a promise --> item.then((response) => { console.log(response) }) -
Resources
- Not all resources have defined methods/classes
- find, update, delete, all are defined on any resource dynamically if the resource URL is standard.
-
ie:
lib.resource('category').find(1)this will create a BasicResource which tries to call "/Category/1.json" if there are special keys they need to be defined in the library. Check resources/item.js for an example.
-
- Running the tests
- Run
yarn testornpm run test
yarn buildornpm run build- produces production version of your library under thelibfolderyarn devornpm run dev- produces development version of your library and runs a watcheryarn testornpm run test- well ... it runs the tests :)yarn test:watchornpm run test:watch- same as above but in a watch mode