node-freebe
v3.1.2
Published
Node module for accessing thr freebe server api
Downloads
11
Readme
Freebe
Nodejs API wrapper for Freebe.
Installation
npm install node-freebe
Usage
// Require the library
var freebe = require('node-freebe')('secret_key');
Making calls to the resources
The resource methods accepts are promisified, but can receive optional callback as the last argument.
// First Option
// freebe.{resource}.{method}
let charge = {
email: '[email protected]',
amount: 1000
};
freebe.transactions.charge(charge, function(error, body) {
console.log(error);
console.log(body);
});
freebe.subaccounts.getBanks(function(error, body) {
console.log(error);
console.log(body);
});
// Second Option
// freebe.{resource}
freebe.transactions.charge(charge)
.then(function(body) {
console.log(body);
})
.catch(function(error) {
console.log(error);
});
freebe.subaccounts.getBanks()
.then(function(body) {
console.log(body);
})
.catch(function(error) {
console.log(error);
});
Resources
- transaction
- charge
- subaccount
- getBanks
Contributing
- To ensure consistent code style, please follow the editorconfig rules in .editorconfig
Tests
To run tests, add your Freebe test secret key to package.json
. (The test line should look something like this: env KEY=sk_test_1a68ac96a0171fb72111a24295d8d31d41c28eed ./node_modules/.bin/mocha...
). Now run:
npm test
If you are contributing to the repo, kindly update the necessary test file in /test
or add a new one and ensure all tests are passed before sending a PR.
Todo
- Proper resource examples
- ES6 support