node-freebe

3.1.2 • Public • Published

Freebe Build status

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: 'somunizua@gmail.com',
    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

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

Package Sidebar

Install

npm i node-freebe

Weekly Downloads

0

Version

3.1.2

License

MIT

Unpacked Size

12 kB

Total Files

10

Last publish

Collaborators

  • theslyone