unismsgateway 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/dist/lib/lib.d.ts +6 -0
- package/dist/lib/lib.js +5 -1
- package/dist/lib/platform.d.ts +13 -1
- package/dist/lib/platform.js +37 -1
- package/package.json +6 -4
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
# Unified Sms Gateway
|
|
3
|
+
|
|
4
|
+
Most of the time a single project relies on multiple sms Gateway so it can switched if one goes off.
|
|
5
|
+
However, each sms api specification is different from the other, hence the need to create separate implementation
|
|
6
|
+
for each sms gateway.
|
|
7
|
+
|
|
8
|
+
Unified sms gateway is library that brings most common sms gateways under a Unified api.
|
|
9
|
+
which means you only does one implementation in it works for all supported sms gateway.
|
|
10
|
+
you just have select or switch your sms platform and your code still works fine like nothing has changed
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Usage/Examples
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
const unisms = require('unismsgateway')
|
|
17
|
+
|
|
18
|
+
const param = { clientId, // hubtel sms client Id **optional
|
|
19
|
+
clientSecret, // hubtel sms client secret ** optional
|
|
20
|
+
username, // username for route sms
|
|
21
|
+
password, // password for route sms
|
|
22
|
+
host, // host address eg. rslr.connectbind.....
|
|
23
|
+
port} // port defaults to 8080
|
|
24
|
+
|
|
25
|
+
//init with prefered platform id. route => routemobile, hubtel => hubtel sms
|
|
26
|
+
// more sms services will be added or supported in the future
|
|
27
|
+
const gateway = unisms.init({platformId:'route', param})
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### SEND MESSAGE
|
|
32
|
+
```javascript
|
|
33
|
+
|
|
34
|
+
const testSms = async function(){
|
|
35
|
+
try{
|
|
36
|
+
// const gateway = unisms.getSmsPlatform();
|
|
37
|
+
await gateway.quickSend({From:'xxxxx', To: xxxxxxxx, Content: 'Testing unisms', Type: 0}, (response)=>{
|
|
38
|
+
console.log(response)
|
|
39
|
+
}).then(r => {
|
|
40
|
+
console.log(r)
|
|
41
|
+
}).catch(err => {
|
|
42
|
+
console.log(err)
|
|
43
|
+
})
|
|
44
|
+
}catch(err){
|
|
45
|
+
console.log(err)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## supported bulk sms gateways
|
|
55
|
+
|
|
56
|
+
Hubtel bulk sms (Ghana) using hubtel-sms-extended
|
|
57
|
+
routeMobile sms (India) using routemobilesms
|
|
58
|
+
Nest SMS(Ghana) using nestsms
|
|
59
|
+
|
|
60
|
+
## Roadmap
|
|
61
|
+
|
|
62
|
+
- Additional browser support
|
|
63
|
+
|
|
64
|
+
- Add more third party sms integrations
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
70
|
+
|
package/dist/lib/lib.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { smsPlatform, IgatewaySettings } from './platform';
|
|
2
2
|
export declare function init(settings: IgatewaySettings): smsPlatform;
|
|
3
3
|
export declare function getSmsPlatform(): smsPlatform;
|
|
4
|
+
export declare function quickSend(param: {
|
|
5
|
+
From: string;
|
|
6
|
+
To: number;
|
|
7
|
+
Content: string;
|
|
8
|
+
Type?: number;
|
|
9
|
+
}, callback?: Function): any;
|
package/dist/lib/lib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSmsPlatform = exports.init = void 0;
|
|
3
|
+
exports.quickSend = exports.getSmsPlatform = exports.init = void 0;
|
|
4
4
|
const platform_1 = require("./platform");
|
|
5
5
|
let smsplatform;
|
|
6
6
|
function init(settings) {
|
|
@@ -13,3 +13,7 @@ function getSmsPlatform() {
|
|
|
13
13
|
return smsplatform;
|
|
14
14
|
}
|
|
15
15
|
exports.getSmsPlatform = getSmsPlatform;
|
|
16
|
+
function quickSend(param, callback) {
|
|
17
|
+
return smsplatform.quickSend(param, callback);
|
|
18
|
+
}
|
|
19
|
+
exports.quickSend = quickSend;
|
package/dist/lib/platform.d.ts
CHANGED
|
@@ -15,10 +15,22 @@ export interface IgatewaySettings {
|
|
|
15
15
|
param: IgatewayParam;
|
|
16
16
|
}
|
|
17
17
|
export interface IgatewayParam {
|
|
18
|
-
host
|
|
18
|
+
host: string;
|
|
19
19
|
port?: number;
|
|
20
20
|
username?: string;
|
|
21
21
|
password?: string;
|
|
22
22
|
clientId?: string;
|
|
23
23
|
clientSecret?: string;
|
|
24
|
+
version: string;
|
|
25
|
+
authModel: AuthModel;
|
|
26
|
+
}
|
|
27
|
+
export interface AuthModel {
|
|
28
|
+
type: AuthTypes;
|
|
29
|
+
username?: string;
|
|
30
|
+
password?: string;
|
|
31
|
+
key?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare enum AuthTypes {
|
|
34
|
+
factor = "factor",
|
|
35
|
+
key = "key"
|
|
24
36
|
}
|
package/dist/lib/platform.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.smsPlatform = void 0;
|
|
22
|
+
exports.AuthTypes = exports.smsPlatform = void 0;
|
|
4
23
|
// const routesms = require('routesms')
|
|
5
24
|
const hubtel_sms_extended_1 = require("hubtel-sms-extended");
|
|
6
25
|
const routemobilesms_1 = require("routemobilesms");
|
|
26
|
+
const nestsms = __importStar(require("nestsms"));
|
|
7
27
|
// routeSms.engine
|
|
8
28
|
class smsPlatform {
|
|
9
29
|
constructor(settings) {
|
|
@@ -21,6 +41,14 @@ class smsPlatform {
|
|
|
21
41
|
// console.log(this._settings)
|
|
22
42
|
this._sms = new hubtel_sms_extended_1.HubtelSms({ clientId: this._settings.param.clientId, clientSecret: this._settings.param.clientSecret });
|
|
23
43
|
}
|
|
44
|
+
else if (this._settings.platformId === 'nest') {
|
|
45
|
+
// console.log(this._settings)
|
|
46
|
+
this._sms = nestsms.init({
|
|
47
|
+
host: this._settings.param.host,
|
|
48
|
+
version: this._settings.param.version,
|
|
49
|
+
authModel: this._settings.param.authModel
|
|
50
|
+
});
|
|
51
|
+
}
|
|
24
52
|
// console.log({sms: this._sms})
|
|
25
53
|
return this;
|
|
26
54
|
}
|
|
@@ -32,9 +60,17 @@ class smsPlatform {
|
|
|
32
60
|
else if (this._settings.platformId === 'hubtel') {
|
|
33
61
|
return this._sms.quickSend(param);
|
|
34
62
|
}
|
|
63
|
+
else if (this._settings.platformId === 'nest') {
|
|
64
|
+
return this._sms.quickSend(param);
|
|
65
|
+
}
|
|
35
66
|
else {
|
|
36
67
|
throw new Error("Platform ID not recognised");
|
|
37
68
|
}
|
|
38
69
|
}
|
|
39
70
|
}
|
|
40
71
|
exports.smsPlatform = smsPlatform;
|
|
72
|
+
var AuthTypes;
|
|
73
|
+
(function (AuthTypes) {
|
|
74
|
+
AuthTypes["factor"] = "factor";
|
|
75
|
+
AuthTypes["key"] = "key";
|
|
76
|
+
})(AuthTypes = exports.AuthTypes || (exports.AuthTypes = {}));
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unismsgateway",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "A unified sms gateway library that brings access to multiple sms gateways under a single API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
9
|
"build": "tsc",
|
|
10
|
-
"prepublish": "npm run build"
|
|
10
|
+
"prepublish": "npm run build",
|
|
11
|
+
"publish":"git push --tags && npm publish"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"dist/**/*"
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"hubtel-sms-extended": "^1.0.2",
|
|
24
|
-
"
|
|
25
|
+
"nestsms": "^1.1.2",
|
|
26
|
+
"routemobilesms": "^1.0.4"
|
|
25
27
|
}
|
|
26
28
|
}
|