From 3ce8118dbe22808f6c21e873a963ea43e867bff7 Mon Sep 17 00:00:00 2001 From: Subomi Date: Sat, 18 Mar 2017 01:10:25 +0100 Subject: [PATCH] Edited README --- README.md | 54 +++++++++++++++++++++++++++++++++++----------------- package.json | 2 +- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3f8eb0f..3c12195 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -## paystack ![Build status](https://travis-ci.org/theslyone/node-paystack.svg?branch=master) +## Paystack ![Build status](https://travis-ci.org/theslyone/node-paystack.svg?branch=master) -Promisified version of the original paystack API wrapper for [Paystack](https://paystack.co/). +Nodejs API wrapper for [Paystack](https://paystack.co/). ### Installation @@ -16,15 +16,29 @@ var paystack = require('paystack')('secret_key'); ``` #### Making calls to the resources -The resource methods accepts an optional callback as the last argument. The callback returns two JSON objects - `error`, which will be null for successful calls, and `body`, the response from the API call. All resources return a promise and hence calls can be cascaded (A callback argument is not required when cascading calls). +The resource methods accepts are promisified, but can receive optional callback as the last argument. ```js +// First Option // paystack.{resource}.{method} paystack.customer.list(function(error, body) { console.log(error); console.log(body); }); ``` +```js +// Second Option +// paystack.{resource} +paystack.customer.list() + .then(function(body) { + console.log(body); + }) + .catch(function(error) { + console.log(error); + }); +``` + + For resource methods that use POST or PUT, the JSON body can be passed as the first argument. @@ -33,28 +47,29 @@ paystack.plan.create({ name: 'API demo', amount: 10000, interval: 'monthly' -},function(error, body) { - console.log(error); - console.log(body); -}); +}) + .then(function(error, body) { + console.log(error); + console.log(body); + }); ``` For GET, you can pass the required ID as string and optional parameters as an optional object argument. ```js -paystack.plan.get(90, function(error, body) { - console.log(error); - console.log(body); -}); +paystack.plan.get(90) + .then(function(error, body) { + console.log(error); + console.log(body); + }); ``` ```js -paystack.transactions.list({ - perPage: 20 -}, function(error, body) { - console.log(error); - console.log(body); -}); +paystack.transactions.list({perPage: 20}) + .then(function(error, body) { + console.log(error); + console.log(body); + }); ``` ### Resources @@ -93,6 +108,11 @@ paystack.transactions.list({ - list - listBanks - update +- Miscellanous + - list_banks + - resolve_bin + + ### Contributing - To ensure consistent code style, please follow the [editorconfig rules](http://obem.be/2015/06/01/a-quick-note-on-editorconfig.html) in .editorconfig diff --git a/package.json b/package.json index 9d262b1..1dc55d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "paystack", - "version": "2.0.0", + "version": "2.0.1", "description": "Paystack API wrapper", "main": "index.js", "scripts": {