diff --git a/README.md b/README.md index de2b5c1..00d9f39 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); - link_id (string) - amount (integer) - `returns`: object +* getBusinesses + - `accepts`: + - channel (string) + - `returns`: object ## Extra diff --git a/lib/Thepeer.js b/lib/Thepeer.js index 0825903..cfa4257 100644 --- a/lib/Thepeer.js +++ b/lib/Thepeer.js @@ -3,13 +3,13 @@ const crypto = require('crypto') const Helper = require('./utils/Helper') /** - * @class ThePeer + * @class Thepeer */ -class ThePeer { +class Thepeer { /** *This is a constructor for creating a Peer Instance * @param {string} secretkey - Thepeer secret key - * @returns { ThePeer } - An instance of thePeer + * @returns { Thepeer } - An instance of Thepeer */ constructor (secretkey) { this.secretKey = secretkey @@ -27,7 +27,7 @@ class ThePeer { * @param {object} payload - The payload to be verified. * @param {string} signature - The signature to compare with * @returns { Boolean } - True if same signature otherwise false - * @memberof ThePeer + * @memberof Thepeer */ validateSignature (payload, signature) { return signature === crypto.createHmac('sha1', this.secretKey).update(payload).digest('hex') @@ -38,7 +38,7 @@ class ThePeer { * @param {string} identifier - The identifier of the user * @param {string} email - The email of the user * @returns {JSON} A JSON response containing the details of the user - * @memberof ThePeer + * @memberof Thepeer */ async indexUser (name, identifier, email) { try { @@ -58,7 +58,7 @@ class ThePeer { * @param {string} reference - The reference returned when the user was indexed * @param {string} identifier - The identifier of the user * @returns {JSON} A JSON response containing the details of the user - * @memberof ThePeer + * @memberof Thepeer */ async updateUser (reference, identifier) { try { @@ -75,7 +75,7 @@ class ThePeer { /** * @param {string} reference - The reference returned when the user was indexed * @returns {JSON} A JSON response containing the details of the user - * @memberof ThePeer + * @memberof Thepeer */ async deleteUser (reference) { try { @@ -90,7 +90,7 @@ class ThePeer { /** * @param {string} reference - The reference returned when the user was indexed * @returns {JSON} A JSON response containing the details of the user - * @memberof ThePeer + * @memberof Thepeer */ async getUser (reference) { try { @@ -106,7 +106,7 @@ class ThePeer { * * @param {string} linkid - The id of a user linked account * @returns {JSON} A JSON response containing the details of the user - * @memberof ThePeer + * @memberof Thepeer */ async getLink (linkid) { try { @@ -124,7 +124,7 @@ class ThePeer { * @param {int} amount - amount in kobo * @param {string} remark - The reason for initiating a direct charge * @returns {JSON} A JSON response containing the details of the user - * @memberof ThePeer + * @memberof Thepeer */ async chargeLink (linkid, amount, remark) { try { @@ -144,7 +144,7 @@ class ThePeer { * @param {*} reference - The direct charge reference sent via webhook * @param {string} event - Event type (success, insufficient_funds) * @returns {JSON} A JSON response containing the details of the user - * @memberof ThePeer + * @memberof Thepeer */ async authorizeCharge (reference, event) { try { @@ -157,6 +157,21 @@ class ThePeer { Helper.processError(e) } } + + /** + * Get a list of all integrated businesses and their respective images + * @param {string} channel - Channel type (send, checkout, direct_charge) + * @returns {JSON} A JSON response containing the details of the businesses + * @memberof Thepeer + */ + async getBusinesses (channel) { + try { + const response = await this.request.get(`/businesses?channel=${channel}`) + return response.data + } catch (e) { + Helper.processError(e) + } + } } -module.exports = ThePeer +module.exports = Thepeer diff --git a/package.json b/package.json index 99ec5a3..7c65e5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "thepeer-node", - "version": "0.0.1", + "version": "0.0.4", "description": "The official node package for Thepeer", "main": "index.js", "scripts": { @@ -17,7 +17,8 @@ }, "contributors": [ "Michael Trojan Okoh ", - "Faithful Ojebiyi " + "Faithful Ojebiyi ", + "Idorenyin Udoh " ], "license": "ISC", "bugs": {