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