unismsgateway 1.0.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.
@@ -0,0 +1 @@
1
+ export * from './lib/lib';
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./lib/lib"), exports);
@@ -0,0 +1,3 @@
1
+ import { smsPlatform, IgatewaySettings } from './platform';
2
+ export declare function init(settings: IgatewaySettings): smsPlatform;
3
+ export declare function getSmsPlatform(): smsPlatform;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSmsPlatform = exports.init = void 0;
4
+ const platform_1 = require("./platform");
5
+ let smsplatform;
6
+ function init(settings) {
7
+ const smsPlatform_ = new platform_1.smsPlatform(settings);
8
+ smsplatform = smsPlatform_;
9
+ return smsPlatform_.init();
10
+ }
11
+ exports.init = init;
12
+ function getSmsPlatform() {
13
+ return smsplatform;
14
+ }
15
+ exports.getSmsPlatform = getSmsPlatform;
@@ -0,0 +1,24 @@
1
+ export declare class smsPlatform {
2
+ _settings: IgatewaySettings;
3
+ _sms: any;
4
+ constructor(settings: IgatewaySettings);
5
+ init(): this;
6
+ quickSend(param: {
7
+ From: string;
8
+ To: number;
9
+ Content: string;
10
+ Type?: number;
11
+ }, callback?: Function): any;
12
+ }
13
+ export interface IgatewaySettings {
14
+ platformId: string;
15
+ param: IgatewayParam;
16
+ }
17
+ export interface IgatewayParam {
18
+ host?: string;
19
+ port?: number;
20
+ username?: string;
21
+ password?: string;
22
+ clientId?: string;
23
+ clientSecret?: string;
24
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.smsPlatform = void 0;
4
+ // const routesms = require('routesms')
5
+ const hubtel_sms_extended_1 = require("hubtel-sms-extended");
6
+ const routemobilesms_1 = require("routemobilesms");
7
+ // routeSms.engine
8
+ class smsPlatform {
9
+ constructor(settings) {
10
+ this._settings = settings;
11
+ }
12
+ init() {
13
+ if (this._settings.platformId === 'route') {
14
+ // this._sms = routesms;
15
+ this._sms = new routemobilesms_1.routeSms({ host: 'rslr.connectbind.com', username: 'nety-dntc', password: '@Alpha12', protocol: 'http', port: 8080 });
16
+ // this._sms = routeSms;
17
+ // console.log(this._sms, this._sms.connection)
18
+ // this._sms.connection = this._settings.param;
19
+ }
20
+ else if (this._settings.platformId === 'hubtel') {
21
+ // console.log(this._settings)
22
+ this._sms = new hubtel_sms_extended_1.HubtelSms({ clientId: this._settings.param.clientId, clientSecret: this._settings.param.clientSecret });
23
+ }
24
+ // console.log({sms: this._sms})
25
+ return this;
26
+ }
27
+ quickSend(param, callback) {
28
+ if (this._settings.platformId === 'route') {
29
+ return this._sms.sendAsync({ From: param.From, To: param.To, Content: param.Content });
30
+ // return this._sms.send(callback);
31
+ }
32
+ else if (this._settings.platformId === 'hubtel') {
33
+ return this._sms.quickSend(param);
34
+ }
35
+ else {
36
+ throw new Error("Platform ID not recognised");
37
+ }
38
+ }
39
+ }
40
+ exports.smsPlatform = smsPlatform;
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "unismsgateway",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "tsc",
10
+ "prepublish": "npm run build"
11
+ },
12
+ "files": [
13
+ "dist/**/*"
14
+ ],
15
+ "keywords": [],
16
+ "author": "",
17
+ "license": "ISC",
18
+ "devDependencies": {
19
+ "@types/node": "^17.0.4",
20
+ "typescript": "^4.5.4"
21
+ },
22
+ "dependencies": {
23
+ "hubtel-sms-extended": "^1.0.2",
24
+ "routemobilesms": "^1.0.3"
25
+ }
26
+ }