diff --git a/README.md b/README.md index d3113bb..00d9f39 100644 --- a/README.md +++ b/README.md @@ -22,16 +22,11 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); - signature (object) - `returns`: boolean -* getSendReceipt +* authorizeCharge - `accepts`: - - receipt_id (string) - - `returns`: object - -* processSendReceipt - - `accepts`: - - receipt_id (string) + - reference (string) - event (string) - - `returns`: object + - `returns`: boolean * indexUser - `accepts`: @@ -53,19 +48,17 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); * getLink - `accepts`: - - lind_id (string) + - link_id (string) - `returns`: object * chargeLink - `accepts`: - - lind_id (string) + - link_id (string) - amount (integer) - `returns`: object - -* authorizeDirectCharge +* getBusinesses - `accepts`: - - reference (string) - - event (string) + - channel (string) - `returns`: object ## Extra diff --git a/lib/Thepeer.js b/lib/Thepeer.js index 388f507..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 { @@ -121,10 +121,10 @@ class ThePeer { /** * A function that charges your user's linked account at any time * @param {string} linkid - The id of the link - * @param {integer} amount - amount in kobo + * @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 { @@ -140,15 +140,15 @@ class ThePeer { } /** - * Authorize direct charge request via webhooks + * Authorize charge request via webhooks * @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 authorizeDirectCharge (reference, event) { + async authorizeCharge (reference, event) { try { - const response = await this.request.post(`/debit/${reference}`, { + const response = await this.request.post(`/authorization/${reference}`, { event: event }) @@ -159,32 +159,14 @@ class ThePeer { } /** - * @memberof ThePeer - * @param {string} receipt - The reference returned to your receiptURL via the Chain SDK - * @param {string} event - Event type (success, insufficient_funds) - * @returns {JSON} A JSON response containing the details of the user - */ - async processSendReceipt (receipt, event) { - try { - const response = await this.request.post(`/send/${receipt}`, { - event: event - }) - - return response.data - } catch (e) { - Helper.processError(e) - } - } - - /** - * @memberof ThePeer - * @param {string} receipt - The reference returned to your receiptURL via the Chain SDK - * @returns {JSON} A JSON response containing the details of the user + * 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 getSendReceipt (receipt) { + async getBusinesses (channel) { try { - const response = await this.request.get(`/send/${receipt}`) - + const response = await this.request.get(`/businesses?channel=${channel}`) return response.data } catch (e) { Helper.processError(e) @@ -192,4 +174,4 @@ class ThePeer { } } -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": {