Advertisement
Bobrovozka

Untitled

Dec 1st, 2020
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. private void sendSmsBySmsc(SMS smsDto, LoginPasswordInterface loginPassword) throws SmsSenderException {
  2.         String phones= smsDto.getRecipients().stream().map(phone -> phone.replaceAll("[^0-9?!\\.]", "")).collect(Collectors.joining(","));
  3.  
  4.         Smsc sd= new Smsc(loginPassword.getLogin(), loginPassword.getPassword());
  5.         String[] res = sd.send_sms(phones, smsDto.getMessageBody(), 0, "", "",0, smsDto.getSenderId(), "");
  6.         /*
  7.          * @return array (<id>, <количество sms>, <стоимость>, <баланс>) в случае успешной отправки
  8.          * или массив (<id>, -<код ошибки>) в случае ошибки
  9.          */
  10.         if(res!=null){
  11.             if(res.length == 2){
  12.                 log.error("sms send error. ID = "+res[0]+".Code = " + res[1]);
  13.                 throw new SmsSenderException("error Code: " + res[1]);
  14.             } else if(res.length == 4){
  15.                 log.info("sms was sent. Id = "+res[0]);
  16.             }
  17.         }
  18.     }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement