Search in sources :

Example 1 with SendSmsResponse

use of io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse 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 2 with SendSmsResponse

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

the class OptSmsServiceImpl method sendSms.

@Override
public SendSmsResponse sendSms(SendSmsRequest sendSmsRequest) {
    checkParam(sendSmsRequest);
    SendSmsResponse acsResponse;
    try {
        if (GlobalConstant.DEV_PROFILE.equals(profile)) {
            log.error("dev环境不发送短信");
            return new SendSmsResponse();
        }
        if (GlobalConstant.TEST_PROFILE.equals(profile)) {
            log.error("test环境不发送短信");
            return new SendSmsResponse();
        }
        acsResponse = iAcsClient.getAcsResponse(sendSmsRequest);
    } catch (ClientException e) {
        log.error("send sms message error={}", e.getMessage(), e);
        throw new OpcBizException(ErrorCodeEnum.OPC10040004, e);
    }
    log.info("send sms message OK acsResponse={}", acsResponse);
    return acsResponse;
}
Also used : ClientException(com.aliyuncs.exceptions.ClientException) OpcBizException(com.paascloud.provider.exceptions.OpcBizException) SendSmsResponse(com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse)

Example 3 with SendSmsResponse

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

the class SmsClientImpl method getResponse.

private Future<JsonObject> getResponse(final SendSmsRequest request) {
    try {
        final SendSmsResponse response = this.client.getAcsResponse(request);
        final JsonObject data = new JsonObject();
        data.put(SmsConfig.RESPONSE_REQUEST_ID, response.getRequestId());
        data.put(SmsConfig.RESPONSE_BUSINESS_ID, response.getBizId());
        data.put(SmsConfig.RESPONSE_CODE, response.getCode());
        data.put(SmsConfig.RESPONSE_MESSAGE, response.getMessage());
        return Future.succeededFuture(data);
    } catch (final ClientException ex) {
        Fn.flingWeb(true, LOGGER, _424MessageSendException.class, this.getClass(), ex);
        return Future.failedFuture(ex);
    }
}
Also used : JsonObject(io.vertx.core.json.JsonObject) ClientException(com.aliyuncs.exceptions.ClientException) SendSmsResponse(com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse) io.vertx.up.exception._424MessageSendException(io.vertx.up.exception._424MessageSendException)

Example 4 with SendSmsResponse

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

the class AliyunSmsSender method sendPasscode.

@Override
public void sendPasscode(String toPhoneNumber, String code) {
    SendSmsRequest request = new SendSmsRequest();
    try {
        request.setMethod(MethodType.POST);
        request.setSignName(signName);
        request.setTemplateCode(passcodeTemplate);
        request.setTemplateParam(String.format(PASSCODE_MESSAGE, code));
        request.setPhoneNumbers(toPhoneNumber);
        SendSmsResponse httpResponse = client.getAcsResponse(request);
    // TODO parse code
    } catch (ServerException e) {
        throw new SmsException(e);
    } catch (ClientException e) {
        throw new SmsException(e);
    }
}
Also used : ServerException(com.aliyuncs.exceptions.ServerException) SendSmsRequest(io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest) ClientException(com.aliyuncs.exceptions.ClientException) SendSmsResponse(io.picos.sailfish.mfa.sms.repackage.com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse) SmsException(io.picos.sailfish.mfa.sms.exception.SmsException)

Aggregations

SendSmsResponse (com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse)3 ClientException (com.aliyuncs.exceptions.ClientException)3 SendSmsRequest (com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest)1 ServerException (com.aliyuncs.exceptions.ServerException)1 OpcBizException (com.paascloud.provider.exceptions.OpcBizException)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 JsonObject (io.vertx.core.json.JsonObject)1 io.vertx.up.exception._424MessageSendException (io.vertx.up.exception._424MessageSendException)1 Test (org.junit.Test)1