dt-common-device 13.3.11 → 13.3.13

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.
@@ -1,2 +1,2 @@
1
1
  export * from "./twilio.service";
2
- export * from "./interface/twilloInterface";
2
+ export * from "./interface/twilioInterface";
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./twilio.service"), exports);
18
- __exportStar(require("./interface/twilloInterface"), exports);
18
+ __exportStar(require("./interface/twilioInterface"), exports);
@@ -0,0 +1,5 @@
1
+ export interface ISendSMSRequest {
2
+ propertyId: string;
3
+ message: string;
4
+ toNumber: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { ISendSMSRequest } from "./interface/twilloInterface";
1
+ import { ISendSMSRequest } from "./interface/twilioInterface";
2
2
  export declare class TwilioService {
3
3
  private readonly connectionRepository;
4
4
  private readonly propertyRepository;
@@ -94,9 +94,15 @@ let TwilioService = (() => {
94
94
  // Send SMS
95
95
  // -----------------------------
96
96
  async sendSMS(data) {
97
- const { propertyId, message } = data;
97
+ const { propertyId, message, toNumber } = data;
98
+ if (!toNumber) {
99
+ return;
100
+ }
98
101
  //find fromNumber from the dt_connections table based on the propertyId
99
- const response = await this.connectionRepository.queryConnections({ propertyId, connectionProvider: IConnection_1.ConnectionProvider.Twilio });
102
+ const response = await this.connectionRepository.queryConnections({
103
+ propertyId,
104
+ connectionProvider: IConnection_1.ConnectionProvider.Twilio,
105
+ });
100
106
  //need connectionId, clientSecret, metaData
101
107
  const { clientId, clientSecret, metaData } = response[0];
102
108
  const fromNumber = metaData?.fromNumber;
@@ -109,14 +115,10 @@ let TwilioService = (() => {
109
115
  throw new Error("Property settings not found");
110
116
  }
111
117
  const smsEnabled = _settingsRes?.settings?.notificationPreferences?.smsNotification?.enabled;
112
- const toNumber = _settingsRes?.settings?.notificationPreferences?.smsNotification?.toNumber;
113
- if (!toNumber) {
114
- return;
115
- }
116
118
  if (!smsEnabled) {
117
119
  return;
118
120
  }
119
- //TODO: Need to do singletone pattern for the client
121
+ //TODO: Need to do single tone pattern for the client
120
122
  const client = (0, twilio_1.default)(clientId, clientSecret);
121
123
  try {
122
124
  const smsResponse = await client.messages.create({
@@ -1,5 +1,10 @@
1
1
  export declare class RedisUtils {
2
2
  private readonly client;
3
+ /**
4
+ * Get the Redis client instance
5
+ * @returns The Redis client instance
6
+ */
7
+ getClient(): Promise<import("ioredis").default>;
3
8
  /**
4
9
  * Get a value from Redis
5
10
  * @param key - The key to get
@@ -50,6 +50,13 @@ let RedisUtils = (() => {
50
50
  constructor() {
51
51
  this.client = (0, redis_1.getRedisClient)(); // singleton Redis client instance
52
52
  }
53
+ /**
54
+ * Get the Redis client instance
55
+ * @returns The Redis client instance
56
+ */
57
+ async getClient() {
58
+ return this.client;
59
+ }
53
60
  /**
54
61
  * Get a value from Redis
55
62
  * @param key - The key to get
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.3.11",
3
+ "version": "13.3.13",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [