Search in sources :

Example 1 with SendSmsRequest

use of io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest in project paascloud-master by paascloud.

the class OptSendSmsTopicConsumer method handlerSendSmsTopic.

/**
 * Handler send sms topic.
 *
 * @param body      the body
 * @param topicName the topic name
 * @param tags      the tags
 * @param keys      the keys
 */
public void handlerSendSmsTopic(String body, String topicName, String tags, String keys) {
    MqMessage.checkMessage(body, keys, topicName);
    SendSmsRequest sendSmsRequest;
    try {
        sendSmsRequest = JacksonUtil.parseJson(body, SendSmsRequest.class);
    } catch (Exception e) {
        log.error("发送短信MQ出现异常={}", e.getMessage(), e);
        throw new IllegalArgumentException("JSON转换异常", e);
    }
    String ipAddr = sendSmsRequest.getOutId();
    if (StringUtils.isEmpty(ipAddr)) {
        throw new IllegalArgumentException("outId不能为空");
    }
    smsService.sendSms(sendSmsRequest);
}
Also used : SendSmsRequest(com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest)

Example 2 with SendSmsRequest

use of io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest in project paascloud-master by paascloud.

the class OptSmsServiceTest method sendMessageProducerTest.

@Test
public void sendMessageProducerTest() throws InterruptedException {
    SendSmsRequest request = new SendSmsRequest();
    // 必填:待发送手机号
    request.setPhoneNumbers("13718891700");
    // 必填:短信签名-可在短信控制台中找到
    request.setSignName("快乐学习网");
    // 必填:短信模板-可在短信控制台中找到
    request.setTemplateCode("SMS_78725128");
    // 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
    request.setTemplateParam("{\"code\":\"963852\"}");
    // 选填-上行短信扩展码(无特殊需求用户请忽略此字段)
    // request.setSmsUpExtendCode("90997");
    // 可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
    request.setOutId("yourOutId");
    SendSmsResponse sendSmsResponse = optSmsService.sendSms(request);
    logger.info("发送 生产数据 sendSmsResponse={}", sendSmsResponse);
}
Also used : SendSmsRequest(com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest) SendSmsResponse(com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse) Test(org.junit.Test)

Example 3 with SendSmsRequest

use of io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest in project vertx-zero by silentbalanceyh.

the class SmsClientImpl method getRequest.

private SendSmsRequest getRequest(final String mobile, final String tplCode, final JsonObject params) {
    final SendSmsRequest request = new SendSmsRequest();
    request.setPhoneNumbers(mobile);
    request.setSignName(this.config.getSignName());
    request.setTemplateCode(tplCode);
    request.setTemplateParam(params.encode());
    return request;
}
Also used : SendSmsRequest(com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest)

Example 4 with SendSmsRequest

use of io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest in project citrus-samples by christophd.

the class FieldForceServiceImpl method process.

@Override
public void process(OrderNotification notification) {
    log.info(String.format("Received FieldForce order notification for ticket '%s' ", notification.getTicketId()));
    if (smsSendStates.contains(notification.getState())) {
        SendSmsRequest sms = new SendSmsRequest();
        sms.setCommunicationId(UUID.randomUUID().toString());
        sms.setCustomerId(notification.getCustomerId());
        switch(notification.getState()) {
            case "ON_SITE":
                sms.setText(String.format("News from ticket '%s' - we started to fix your problem!", notification.getTicketId()));
                break;
            case "FIXED":
                sms.setText(String.format("News from ticket '%s' - your problem is solved!", notification.getTicketId()));
                break;
            case "ABORTED":
                sms.setText(String.format("News from ticket '%s' - we stopped processing your issue! Reason: %s", notification.getTicketId(), notification.getReason().value()));
                break;
            default:
                sms.setText(String.format("News from ticket '%s' - %s", notification.getTicketId(), notification.getState()));
        }
        log.info(String.format("Send SMS message for field force notification state '%s'", notification.getState()));
        if (!smsService.sendSms(sms)) {
            log.warn("Send SMS failed!");
        }
    } else {
        log.info(String.format("Ignore field force notification state '%s'", notification.getState()));
    }
}
Also used : SendSmsRequest(org.citrusframework.schema.samples.smsgateway.v1.SendSmsRequest)

Example 5 with SendSmsRequest

use of io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest in project ranch by heisedebaise.

the class AliyunSmsSenderImpl method send.

@Override
public boolean send(PushModel push, String receiver, JSONObject args) {
    if (acsClient == null)
        return false;
    try {
        SendSmsRequest request = new SendSmsRequest();
        request.setMethod(MethodType.POST);
        request.setPhoneNumbers(receiver);
        request.setSignName(push.getName());
        request.setTemplateCode(push.getTemplate());
        if (!validator.isEmpty(args))
            request.setTemplateParam(args.toJSONString());
        return "OK".equals(acsClient.getAcsResponse(request).getCode());
    } catch (Exception e) {
        logger.warn(e, "通过阿里云发送短信[{}:{}:{}]时发生异常!", receiver, modelHelper.toJson(push), args);
        return false;
    }
}
Also used : SendSmsRequest(com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest)

Aggregations

SendSmsRequest (com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest)5 SendSmsResponse (com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse)1 ClientException (com.aliyuncs.exceptions.ClientException)1 ServerException (com.aliyuncs.exceptions.ServerException)1 SmsException (io.picos.sailfish.mfa.sms.exception.SmsException)1 SendSmsRequest (io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest)1 SendSmsResponse (io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse)1 SendSmsRequest (org.citrusframework.schema.samples.smsgateway.v1.SendSmsRequest)1 Test (org.junit.Test)1