unismsgateway 1.0.1 → 1.1.1

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 CHANGED
@@ -55,8 +55,7 @@ const testSms = async function(){
55
55
 
56
56
  Hubtel bulk sms (Ghana) using hubtel-sms-extended
57
57
  routeMobile sms (India) using routemobilesms
58
-
59
-
58
+ Nest SMS(Ghana) using nestsms
60
59
 
61
60
  ## Roadmap
62
61
 
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;
@@ -15,10 +15,22 @@ export interface IgatewaySettings {
15
15
  param: IgatewayParam;
16
16
  }
17
17
  export interface IgatewayParam {
18
- host?: string;
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
  }
@@ -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) {
@@ -12,7 +32,13 @@ class smsPlatform {
12
32
  init() {
13
33
  if (this._settings.platformId === 'route') {
14
34
  // this._sms = routesms;
15
- this._sms = new routemobilesms_1.routeSms({ host: 'rslr.connectbind.com', username: 'nety-dntc', password: '@Alpha12', protocol: 'http', port: 8080 });
35
+ this._sms = new routemobilesms_1.routeSms({
36
+ host: this._settings.param.host,
37
+ username: this._settings.param.username,
38
+ password: this._settings.param.password,
39
+ protocol: 'http',
40
+ port: 8080
41
+ });
16
42
  // this._sms = routeSms;
17
43
  // console.log(this._sms, this._sms.connection)
18
44
  // this._sms.connection = this._settings.param;
@@ -21,6 +47,14 @@ class smsPlatform {
21
47
  // console.log(this._settings)
22
48
  this._sms = new hubtel_sms_extended_1.HubtelSms({ clientId: this._settings.param.clientId, clientSecret: this._settings.param.clientSecret });
23
49
  }
50
+ else if (this._settings.platformId === 'nest') {
51
+ // console.log(this._settings)
52
+ this._sms = nestsms.init({
53
+ host: this._settings.param.host,
54
+ version: this._settings.param.version,
55
+ authModel: this._settings.param.authModel
56
+ });
57
+ }
24
58
  // console.log({sms: this._sms})
25
59
  return this;
26
60
  }
@@ -32,9 +66,17 @@ class smsPlatform {
32
66
  else if (this._settings.platformId === 'hubtel') {
33
67
  return this._sms.quickSend(param);
34
68
  }
69
+ else if (this._settings.platformId === 'nest') {
70
+ return this._sms.quickSend(param);
71
+ }
35
72
  else {
36
73
  throw new Error("Platform ID not recognised");
37
74
  }
38
75
  }
39
76
  }
40
77
  exports.smsPlatform = smsPlatform;
78
+ var AuthTypes;
79
+ (function (AuthTypes) {
80
+ AuthTypes["factor"] = "factor";
81
+ AuthTypes["key"] = "key";
82
+ })(AuthTypes = exports.AuthTypes || (exports.AuthTypes = {}));
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "unismsgateway",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
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
- "routemobilesms": "^1.0.3"
25
+ "nestsms": "^1.1.2",
26
+ "routemobilesms": "^1.0.4"
25
27
  }
26
28
  }