mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add type definitions for mpesa-node (#46003)
This commit is contained in:
parent
607b638249
commit
8f4efcd2ee
49
types/mpesa-node/index.d.ts
vendored
Normal file
49
types/mpesa-node/index.d.ts
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
// Type definitions for mpesa-node 0.1
|
||||
// Project: https://github.com/safaricom/mpesa-node-library#readme
|
||||
// Definitions by: Peter Munyao <https://github.com/petekmunz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { AxiosPromise } from 'axios';
|
||||
|
||||
declare class Mpesa {
|
||||
constructor(config: ConfigOptions);
|
||||
|
||||
accountBalance(shortCode: string, idType: string, queueUrl: string, resultUrl: string, remarks?: string, initiator?: string, commandId?: string): AxiosPromise;
|
||||
|
||||
b2b(senderParty: string, receiverParty: string, amount: number, queueUrl: string, resultUrl: string, senderType?: number, receiverType?: number, initiator?: string,
|
||||
commandId?: string, accountRef?: string, remarks?: string): AxiosPromise;
|
||||
|
||||
b2c(senderParty: string, receiverParty: string, amount: number, queueUrl: string, resultUrl: string, commandId?: string, initiatorName?: string,
|
||||
remarks?: string, occasion?: string): AxiosPromise;
|
||||
|
||||
c2bRegister(confirmationUrl: string, validationUrl: string, shortCode?: string, responseType?: string): AxiosPromise;
|
||||
|
||||
c2bSimulate(msisdn: string, amount: number, billRefNumber: string, commandId?: string, shortCode?: string): AxiosPromise;
|
||||
|
||||
lipaNaMpesaOnline(senderMsisdn: string, amount: number, callbackUrl: string, accountRef: string, transactionDesc?: string,
|
||||
transactionType?: string, shortCode?: string, passKey?: string): AxiosPromise;
|
||||
|
||||
lipaNaMpesaQuery(checkoutRequestId: string, shortCode?: string, passKey?: string): AxiosPromise;
|
||||
|
||||
oAuth(consumerKey: string, consumerSecret: string, baseURL?: string): AxiosPromise;
|
||||
|
||||
reversal(transactionId: string, amount: number, queueUrl: string, resultUrl: string,
|
||||
shortCode?: string, remarks?: string, occasion?: string, initiator?: string, receiverIdType?: string, commandId?: string): AxiosPromise;
|
||||
|
||||
transactionStatus(transactionId: string, amount: number, queueUrl: string, resultUrl: string, shortCode?: string, remarks?: string,
|
||||
occasion?: string, initiator?: string, receiverIdType?: string, commandId?: string): AxiosPromise;
|
||||
}
|
||||
|
||||
interface ConfigOptions {
|
||||
consumerKey: string;
|
||||
consumerSecret: string;
|
||||
enviroment?: string;
|
||||
shortCode?: string;
|
||||
initiatorName?: string;
|
||||
lipaNaMpesaShortCode?: string;
|
||||
lipaNaMpesaShortPass?: string;
|
||||
securityCredential?: string;
|
||||
certPath?: string;
|
||||
}
|
||||
|
||||
export = Mpesa;
|
||||
23
types/mpesa-node/mpesa-node-tests.ts
Normal file
23
types/mpesa-node/mpesa-node-tests.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import Mpesa = require('mpesa-node');
|
||||
|
||||
const mpesaClient = new Mpesa({ consumerKey: 'test', consumerSecret: 'test' });
|
||||
|
||||
mpesaClient.accountBalance('600111', '4', 'someurl/queue', 'someurl/result'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.b2b('600100', '600000', 500, 'someurl/queue', 'someurl/result'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.b2c('600100', '254722123456', 56, 'someurl/queue', 'someurl/result'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.c2bRegister('someurl/confirmation', 'someurl/validation'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.c2bSimulate('254722123456', 98, '123456'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.lipaNaMpesaOnline('254722123456', 45, 'someurl/callback', 'accountref'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.lipaNaMpesaQuery('wsyhjk6455opp'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.oAuth('consumerkey', 'consumersecret'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.reversal('WSDFR578', 456, 'someurl/queue', 'someurl/result'); // $ExpectType AxiosPromise<any>
|
||||
|
||||
mpesaClient.transactionStatus('WSDFR578', 578, 'someurl/queue', 'someurl/result'); // $ExpectType AxiosPromise<any>
|
||||
6
types/mpesa-node/package.json
Normal file
6
types/mpesa-node/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2"
|
||||
}
|
||||
}
|
||||
23
types/mpesa-node/tsconfig.json
Normal file
23
types/mpesa-node/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mpesa-node-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/mpesa-node/tslint.json
Normal file
1
types/mpesa-node/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user