From 5bd3dd2e70751468ac5c857a929549ba7a8d83a5 Mon Sep 17 00:00:00 2001 From: Peter Smart Date: Sun, 28 Mar 2021 19:12:46 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20convert=20partyIdType=20t?= =?UTF-8?q?o=20lowercase=20to=20avoid=20404=20from=20momo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sending uppercase representation of partyIdType in disbursements isPayerActive api returns 404 but works in transfer request body. Hence, partyIdType is converted to lowercase before including in the uri --- src/disbursements.ts | 2 +- test/disbursements.test.ts | 2 +- test/mock.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/disbursements.ts b/src/disbursements.ts index 7cbf955..7957484 100644 --- a/src/disbursements.ts +++ b/src/disbursements.ts @@ -177,7 +177,7 @@ export default class Disbursements { type: PartyIdType = PartyIdType.MSISDN ): Promise { return this.client - .get(`/disbursement/v1_0/accountholder/${type}/${id}/active`) + .get(`/disbursement/v1_0/accountholder/${String(type).toLowerCase()}/${id}/active`) .then(response => response.data); } } diff --git a/test/disbursements.test.ts b/test/disbursements.test.ts index 2876153..c8d3b6a 100644 --- a/test/disbursements.test.ts +++ b/test/disbursements.test.ts @@ -151,7 +151,7 @@ describe("Disbursements", function() { ).to.be.fulfilled.then(() => { expect(mockAdapter.history.get).to.have.lengthOf(1); expect(mockAdapter.history.get[0].url).to.eq( - "/disbursement/v1_0/accountholder/MSISDN/0772000000/active" + "/disbursement/v1_0/accountholder/msisdn/0772000000/active" ); }); }); diff --git a/test/mock.ts b/test/mock.ts index 24e76a0..21532cd 100644 --- a/test/mock.ts +++ b/test/mock.ts @@ -61,7 +61,7 @@ export function createMock(): [AxiosInstance, MockAdapter] { mock .onGet( - /\/disbursement\/v1_0\/accountholder\/(MSISDN|EMAIL|PARTY_CODE)\/\w+/ + /\/disbursement\/v1_0\/accountholder\/(msisdn|email|party_code)\/\w+/ ) .reply(200, "true");