safaricom / mpesa-node-library

M-Pesa Library for Node.js using REST API
Apache License 2.0
161 stars 139 forks source link

Typescript Conversion RFC #18

Closed williamluke4 closed 5 years ago

williamluke4 commented 5 years ago

This is a first pass at converting to typescript, tests have not been run yet

williamluke4 commented 5 years ago

Am I correct in saying that the integration test does not work in the master branch?

geofmureithi-zz commented 5 years ago

Tests should pass. EG: https://travis-ci.org/safaricom/mpesa-node-library/builds/461261949 Sometimes Daraja may need tests to be executed again due to unexpected HTTP500 responses. Your build does not even contact Daraja.

geofmureithi-zz commented 5 years ago

Sadly your changes are also breaking which is not desirable at the moment.

mpesaApi.c2bRegister(URL + '/c2b/validation', URL + '/c2b/success')

is now

mpesaApi.c2bRegister(options)

I do understand the feeling to use an object, but there are reasons why we decided to go with arguments:

Maybe in version 2 we can use Typescript but then the direction will be different as shown below:

export type B2BOptions = {
  senderParty: number;
  receiverParty: number;
  amount: number;
  queueUrl: string;
  resultUrl: string;
  senderType?: number;
  receiverType?: number;
  initiator?: string;
  commandId?: string;
  accountRef?: string;
  remarks?: string;
};
// May be broken down
export type Sender = {
   senderParty: number;
   senderType?: number;
   initiator?: string;
}
......
geofmureithi-zz commented 5 years ago

Closing because it's breaking the current API. Feel free to start an issue for version 2 and then we can first discuss the way forward.

geofmureithi-zz commented 5 years ago

Link to v0.2.0 https://github.com/safaricom/mpesa-node-library/milestone/1