From 70f9573fa16adbc76b321de46799ea97090fb45b Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Wed, 1 Feb 2023 13:58:51 +0100 Subject: [PATCH 1/6] refactor: rename ThePeer class to Thepeer --- lib/Thepeer.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Thepeer.js b/lib/Thepeer.js index 0825903..9f2d00a 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 { @@ -159,4 +159,4 @@ class ThePeer { } } -module.exports = ThePeer +module.exports = Thepeer From 1f6b085046fba60563ea7546ebbd7b5a2e1c4b2b Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Wed, 1 Feb 2023 14:16:48 +0100 Subject: [PATCH 2/6] feat: factor in get businesses endpoint and reflect on readme --- README.md | 4 ++++ lib/Thepeer.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) 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 9f2d00a..78c9cf8 100644 --- a/lib/Thepeer.js +++ b/lib/Thepeer.js @@ -157,6 +157,25 @@ 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 { + let url = '/businesses' + if (channel.length !== 0) { + url += `?channel=${channel}` + } + const response = await this.request.get(url) + return response.data + } catch (e) { + Helper.processError(e) + } + } } module.exports = Thepeer From ffcab8bff7fd7f4f475d88c806c7d886c18f2ea0 Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Wed, 1 Feb 2023 15:01:24 +0100 Subject: [PATCH 3/6] fix: remove check for empty channel property --- lib/Thepeer.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/Thepeer.js b/lib/Thepeer.js index 78c9cf8..cfa4257 100644 --- a/lib/Thepeer.js +++ b/lib/Thepeer.js @@ -166,11 +166,7 @@ class Thepeer { */ async getBusinesses (channel) { try { - let url = '/businesses' - if (channel.length !== 0) { - url += `?channel=${channel}` - } - const response = await this.request.get(url) + const response = await this.request.get(`/businesses?channel=${channel}`) return response.data } catch (e) { Helper.processError(e) From 4f07fef0f10c6f55a7006ad16d8df8f2f7d22db0 Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Wed, 1 Feb 2023 16:02:42 +0100 Subject: [PATCH 4/6] chore: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99ec5a3..3d2de02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "thepeer-node", - "version": "0.0.1", + "version": "0.0.2", "description": "The official node package for Thepeer", "main": "index.js", "scripts": { From 3c7f4a5e55e631ab27f6ad7114022f1495e68d4a Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Wed, 1 Feb 2023 16:05:51 +0100 Subject: [PATCH 5/6] chore: add idorenyin as contributor --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d2de02..4db3928 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ }, "contributors": [ "Michael Trojan Okoh ", - "Faithful Ojebiyi " + "Faithful Ojebiyi ", + "Idorenyin Udoh " ], "license": "ISC", "bugs": { From 17595b1b71f0f99969f4895359fd18813d9690ba Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Wed, 1 Feb 2023 16:27:02 +0100 Subject: [PATCH 6/6] chore: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4db3928..7c65e5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "thepeer-node", - "version": "0.0.2", + "version": "0.0.4", "description": "The official node package for Thepeer", "main": "index.js", "scripts": {