dt-common-device 13.3.13 → 13.3.14

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.
@@ -95,14 +95,16 @@ let TwilioService = (() => {
95
95
  // -----------------------------
96
96
  async sendSMS(data) {
97
97
  const { propertyId, message, toNumber } = data;
98
+ console.log("TwilioService: sendSMS called with data:", data);
98
99
  if (!toNumber) {
99
- return;
100
+ throw new Error("To number is required for sending SMS");
100
101
  }
101
102
  //find fromNumber from the dt_connections table based on the propertyId
102
103
  const response = await this.connectionRepository.queryConnections({
103
104
  propertyId,
104
105
  connectionProvider: IConnection_1.ConnectionProvider.Twilio,
105
106
  });
107
+ console.log("-------TwilioService: queryConnections response:-----", response);
106
108
  //need connectionId, clientSecret, metaData
107
109
  const { clientId, clientSecret, metaData } = response[0];
108
110
  const fromNumber = metaData?.fromNumber;
@@ -111,21 +113,25 @@ let TwilioService = (() => {
111
113
  }
112
114
  //find toNumber and sms_enabled from the property settings table based on the propertyId
113
115
  const _settingsRes = await this.propertyRepository.getPropertyPreferences(propertyId);
116
+ console.log("-------TwilioService: getPropertyPreferences response:-----", _settingsRes);
114
117
  if (!_settingsRes) {
115
118
  throw new Error("Property settings not found");
116
119
  }
117
120
  const smsEnabled = _settingsRes?.settings?.notificationPreferences?.smsNotification?.enabled;
121
+ console.log("-------TwilioService: smsEnabled response:-----", smsEnabled);
118
122
  if (!smsEnabled) {
119
- return;
123
+ throw new Error("SMS notifications are not enabled for this property");
120
124
  }
121
125
  //TODO: Need to do single tone pattern for the client
122
126
  const client = (0, twilio_1.default)(clientId, clientSecret);
127
+ console.log("------TwilioService: Twilio client initialized------");
123
128
  try {
124
129
  const smsResponse = await client.messages.create({
125
130
  body: message,
126
131
  from: fromNumber,
127
132
  to: toNumber,
128
133
  });
134
+ console.log("---------TwilioService: SMS sent response:---------", smsResponse);
129
135
  return smsResponse;
130
136
  }
131
137
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.3.13",
3
+ "version": "13.3.14",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [