use of org.thingsboard.rule.engine.api.sms.exception.SmsSendException in project thingsboard by thingsboard.
the class AwsSmsSender method sendSms.
@Override
public int sendSms(String numberTo, String message) throws SmsException {
numberTo = this.validatePhoneNumber(numberTo);
message = this.prepareMessage(message);
try {
PublishRequest publishRequest = new PublishRequest().withMessageAttributes(SMS_ATTRIBUTES).withPhoneNumber(numberTo).withMessage(message);
this.snsClient.publish(publishRequest);
return this.countMessageSegments(message);
} catch (Exception e) {
throw new SmsSendException("Failed to send SMS message - " + e.getMessage(), e);
}
}
use of org.thingsboard.rule.engine.api.sms.exception.SmsSendException in project thingsboard by thingsboard.
the class TwilioSmsSender method sendSms.
@Override
public int sendSms(String numberTo, String message) throws SmsException {
numberTo = this.validatePhoneNumber(numberTo);
message = this.prepareMessage(message);
try {
String numSegments = Message.creator(new PhoneNumber(numberTo), new PhoneNumber(this.numberFrom), message).create(this.twilioRestClient).getNumSegments();
return Integer.valueOf(numSegments);
} catch (Exception e) {
throw new SmsSendException("Failed to send SMS message - " + e.getMessage(), e);
}
}
Aggregations