/regaliator_node

Nodejs client library for connecting to the Regalii API.

Primary LanguageJavaScriptMIT LicenseMIT

Regalii Node.js Client

A Node.js client for connecting to the Regalii API.

The client is tested and compatible with the following versions of Node.js:

  • v4.7.2 ;
  • v5.12.0 ;
  • v6.9.4 ;
  • v7.4.0.

Usage

Example:

const Regaliator = require('regaliator');

const client = new Regaliator(
  'https://test.casiregalii.com',
  processs.env.REGALII_API_KEY,
  processs.env.REGALII_SECRET
);

client.account().then((args) => {
  console.log(args.body)
});

All methods of the object regaliator returns a Promise. In case of success, an object having the following keys:

  • body: The decoded JSON response ;
  • req: The request emitted ;
  • res: The response returned by server.

For instance, to get all arguments:

client.account().then((args) => console.log(args.body));

Examples

Examples of some common use-cases:

Creating a credential bill

client.createCredentialsBill(12376, 'login', 'challengeme').then((args) => {
  console.log('Created bill ' + args.body.id);
});

Polling for while bill updating

Coming soon.

Answering MFA Challenge

Coming soon.

Test

To test with your current version of Node.js:

npm test

If you want to test in multiple versions (requires Docker), run:

# For the first time:
npm install -g node-docker-test
ndt --setup

# Then, each time you want:
ndt

Todo

  • Factor test code:
    • Repetitive parts ;
    • Fake server init.
  • Expose some private method as function ;
  • Implement missing methods existing on Ruby client.