From dea19595b62a5b0371b98521ef2100921197b084 Mon Sep 17 00:00:00 2001 From: Fawaz Haroun <64801061+Exalted100@users.noreply.github.com> Date: Fri, 15 Oct 2021 07:51:00 +0100 Subject: [PATCH 01/13] Update Fixed a couple of typos with the available methods. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6510736..f9b81f8 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); ### Available methods -* validateSiganture +* validateSignature - `accepts`: - request (object) - signature (object) @@ -62,7 +62,7 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); - amount (integer) - `returns`: object -* authorizaDirectCharge +* authorizeDirectCharge - `accepts`: - reference (string) - insufficient_funds (bool) @@ -70,4 +70,4 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); ## Extra -Refer to the [documentation](https://docs.thepeer.co) for more information. \ No newline at end of file +Refer to the [documentation](https://docs.thepeer.co) for more information. From 4067fa0855481287560d7454e072aa47566776a2 Mon Sep 17 00:00:00 2001 From: Trojan Date: Thu, 9 Dec 2021 03:07:09 +0100 Subject: [PATCH 02/13] Update methods to match updated API --- lib/Thepeer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Thepeer.js b/lib/Thepeer.js index 7465923..388f507 100644 --- a/lib/Thepeer.js +++ b/lib/Thepeer.js @@ -142,14 +142,14 @@ class ThePeer { /** * Authorize direct charge request via webhooks * @param {*} reference - The direct charge reference sent via webhook - * @param {boolean} insufficientFunds - Status of user funds + * @param {string} event - Event type (success, insufficient_funds) * @returns {JSON} A JSON response containing the details of the user * @memberof ThePeer */ - async authorizeDirectCharge (reference, insufficientFunds) { + async authorizeDirectCharge (reference, event) { try { const response = await this.request.post(`/debit/${reference}`, { - insufficient_funds: insufficientFunds + event: event }) return response.data @@ -161,13 +161,13 @@ class ThePeer { /** * @memberof ThePeer * @param {string} receipt - The reference returned to your receiptURL via the Chain SDK - * @param {boolean} insufficientFunds - Status of user funds + * @param {string} event - Event type (success, insufficient_funds) * @returns {JSON} A JSON response containing the details of the user */ - async processSendReceipt (receipt, insufficientFunds) { + async processSendReceipt (receipt, event) { try { const response = await this.request.post(`/send/${receipt}`, { - insufficient_funds: insufficientFunds + event: event }) return response.data From 38679cdf12cd1fbef57025538358f25186f7551b Mon Sep 17 00:00:00 2001 From: Trojan Date: Thu, 9 Dec 2021 03:08:33 +0100 Subject: [PATCH 03/13] updated to match docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9b81f8..d3113bb 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); * processSendReceipt - `accepts`: - receipt_id (string) - - insufficient_funds (bool) + - event (string) - `returns`: object * indexUser @@ -65,7 +65,7 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); * authorizeDirectCharge - `accepts`: - reference (string) - - insufficient_funds (bool) + - event (string) - `returns`: object ## Extra From 6ecec6d0ea0416d9fffbef5c67b7b1adaad3f0dc Mon Sep 17 00:00:00 2001 From: Trojan Date: Sun, 20 Mar 2022 22:07:13 +0100 Subject: [PATCH 04/13] remove redundant methods --- README.md | 6 ------ lib/Thepeer.js | 33 --------------------------------- 2 files changed, 39 deletions(-) diff --git a/README.md b/README.md index d3113bb..0a1d362 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,6 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); - lind_id (string) - amount (integer) - `returns`: object - -* authorizeDirectCharge - - `accepts`: - - reference (string) - - event (string) - - `returns`: object ## Extra diff --git a/lib/Thepeer.js b/lib/Thepeer.js index 388f507..dc81ef6 100644 --- a/lib/Thepeer.js +++ b/lib/Thepeer.js @@ -157,39 +157,6 @@ class ThePeer { Helper.processError(e) } } - - /** - * @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 - */ - async getSendReceipt (receipt) { - try { - const response = await this.request.get(`/send/${receipt}`) - - return response.data - } catch (e) { - Helper.processError(e) - } - } } module.exports = ThePeer From 43f1c933e300469d8c4c6d9bbb957d2440a1eb96 Mon Sep 17 00:00:00 2001 From: Trojan Date: Sun, 20 Mar 2022 22:07:33 +0100 Subject: [PATCH 05/13] update charge method to new endpoint --- README.md | 12 +++--------- lib/Thepeer.js | 8 ++++---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0a1d362..67bd198 100644 --- a/README.md +++ b/README.md @@ -22,16 +22,10 @@ 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) - - event (string) - - `returns`: object + - charge_id (string) + - `returns`: boolean * indexUser - `accepts`: diff --git a/lib/Thepeer.js b/lib/Thepeer.js index dc81ef6..0825903 100644 --- a/lib/Thepeer.js +++ b/lib/Thepeer.js @@ -121,7 +121,7 @@ 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 @@ -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 */ - 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 }) From 50dc83ca57c64bcbda72e31faf82050f2b46f60e Mon Sep 17 00:00:00 2001 From: Trojan Date: Sun, 20 Mar 2022 22:27:23 +0100 Subject: [PATCH 06/13] hotfix to documentation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 67bd198..ac3b13e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); * authorizeCharge - `accepts`: - charge_id (string) + - event (string) - `returns`: boolean * indexUser From d2039382c1fc7b67e8037821a895c7b23d7fd143 Mon Sep 17 00:00:00 2001 From: Trojan Date: Sun, 20 Mar 2022 22:28:42 +0100 Subject: [PATCH 07/13] hotfix to documentation --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ac3b13e..de2b5c1 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ let user = thepeer.indexUser("Thor Odin", "thor", "thor@odin.com"); * authorizeCharge - `accepts`: - - charge_id (string) + - reference (string) - event (string) - `returns`: boolean @@ -48,12 +48,12 @@ 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 From 70f9573fa16adbc76b321de46799ea97090fb45b Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Wed, 1 Feb 2023 13:58:51 +0100 Subject: [PATCH 08/13] 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 09/13] 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 10/13] 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 11/13] 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 12/13] 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 13/13] 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": {