unismsgateway 1.0.3 → 1.2.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
@@ -46,6 +46,29 @@ const testSms = async function(){
46
46
  }
47
47
 
48
48
 
49
+ }
50
+
51
+ ```
52
+
53
+ ### SEND PERSONALIZED MESSAGE
54
+ ```javascript
55
+
56
+ const testSms = async function(){
57
+ try{
58
+ // const gateway = unisms.getSmsPlatform();
59
+ await gateway.sendPersonalized({From:'xxxxx',
60
+ To: {to: 233XXXXXXXXX, values: ['Alpha', 65332]}, // [{to: 233XXXXXXXXX, values: ['Alpha', 65332]}, {to: 211XXXXXXXXX, values: ['James', 2000]}, ]
61
+ Content: 'Testing unisms',
62
+ Type: 0}).then(r => {
63
+ console.log(r)
64
+ }).catch(err => {
65
+ console.log(err)
66
+ })
67
+ }catch(err){
68
+ console.log(err)
69
+ }
70
+
71
+
49
72
  }
50
73
 
51
74
  ```
@@ -55,8 +78,7 @@ const testSms = async function(){
55
78
 
56
79
  Hubtel bulk sms (Ghana) using hubtel-sms-extended
57
80
  routeMobile sms (India) using routemobilesms
58
-
59
-
81
+ Nest SMS(Ghana) using nestsms
60
82
 
61
83
  ## Roadmap
62
84
 
package/dist/lib/lib.d.ts CHANGED
@@ -1,3 +1,10 @@
1
- import { smsPlatform, IgatewaySettings } from './platform';
1
+ import { smsPlatform, IgatewaySettings, IQuickSendPersonalized } 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;
10
+ export declare function sendPersonalized(body: IQuickSendPersonalized): 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.sendPersonalized = 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,11 @@ 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;
20
+ function sendPersonalized(body) {
21
+ return smsplatform.sendPersonalized(body);
22
+ }
23
+ exports.sendPersonalized = sendPersonalized;
@@ -9,16 +9,43 @@ export declare class smsPlatform {
9
9
  Content: string;
10
10
  Type?: number;
11
11
  }, callback?: Function): any;
12
+ sendPersonalized(body: IQuickSendPersonalized): any;
12
13
  }
13
14
  export interface IgatewaySettings {
14
15
  platformId: string;
15
16
  param: IgatewayParam;
16
17
  }
17
18
  export interface IgatewayParam {
18
- host?: string;
19
+ host: string;
19
20
  port?: number;
20
21
  username?: string;
21
22
  password?: string;
22
23
  clientId?: string;
23
24
  clientSecret?: string;
25
+ version: string;
26
+ authModel: AuthModel;
27
+ }
28
+ export interface AuthModel {
29
+ type: AuthTypes;
30
+ username?: string;
31
+ password?: string;
32
+ key?: string;
33
+ }
34
+ export declare enum AuthTypes {
35
+ factor = "factor",
36
+ key = "key"
37
+ }
38
+ export interface IQuickSendPersonalized {
39
+ From: string;
40
+ Content: string;
41
+ Type: MessageTypes;
42
+ To: IPersonalizedDestination | IPersonalizedDestination[];
43
+ }
44
+ export interface IPersonalizedDestination {
45
+ to: number;
46
+ values: (string | number)[];
47
+ }
48
+ export declare enum MessageTypes {
49
+ Text = 0,
50
+ flash = 1
24
51
  }
@@ -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.MessageTypes = 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,28 @@ 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
  }
76
+ sendPersonalized(body) {
77
+ if (this._settings.platformId !== 'nest') {
78
+ throw new Error("Specified platform does not support personalisation");
79
+ }
80
+ return this._sms.sendPersonalized(body);
81
+ }
39
82
  }
40
83
  exports.smsPlatform = smsPlatform;
84
+ var AuthTypes;
85
+ (function (AuthTypes) {
86
+ AuthTypes["factor"] = "factor";
87
+ AuthTypes["key"] = "key";
88
+ })(AuthTypes = exports.AuthTypes || (exports.AuthTypes = {}));
89
+ var MessageTypes;
90
+ (function (MessageTypes) {
91
+ MessageTypes[MessageTypes["Text"] = 0] = "Text";
92
+ MessageTypes[MessageTypes["flash"] = 1] = "flash";
93
+ })(MessageTypes = exports.MessageTypes || (exports.MessageTypes = {}));
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "unismsgateway",
3
- "version": "1.0.3",
3
+ "version": "1.2.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
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/RazakAlpha/unismsgateway"
10
+ },
7
11
  "scripts": {
8
12
  "test": "echo \"Error: no test specified\" && exit 1",
9
13
  "build": "tsc",
10
- "prepublish": "npm run build"
14
+ "prepublish": "npm run build",
15
+ "publish": "git push --tags && npm publish"
11
16
  },
12
17
  "files": [
13
18
  "dist/**/*"
@@ -21,6 +26,7 @@
21
26
  },
22
27
  "dependencies": {
23
28
  "hubtel-sms-extended": "^1.0.2",
29
+ "nestsms": "^1.2.1",
24
30
  "routemobilesms": "^1.0.4"
25
31
  }
26
32
  }