Search in sources :

Example 16 with ClientException

use of com.aliyuncs.exceptions.ClientException 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

ClientException (com.aliyuncs.exceptions.ClientException)16 HttpResponse (com.aliyuncs.http.HttpResponse)4 IOException (java.io.IOException)4 Test (org.junit.Test)4 InstanceProfileCredentialsFetcher (com.aliyun.oss.common.auth.InstanceProfileCredentialsFetcher)3 InstanceProfileCredentialsFetcherMock (com.aliyun.oss.common.provider.mock.InstanceProfileCredentialsFetcherMock)2 SendSmsResponse (com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse)2 JsonObject (io.vertx.core.json.JsonObject)2 CredentialsProvider (com.aliyun.oss.common.auth.CredentialsProvider)1 PublicKey (com.aliyun.oss.common.auth.PublicKey)1 DefaultAcsClient (com.aliyuncs.DefaultAcsClient)1 AssumeRoleRequest (com.aliyuncs.auth.sts.AssumeRoleRequest)1 AssumeRoleResponse (com.aliyuncs.auth.sts.AssumeRoleResponse)1 GetSessionAccessKeyRequest (com.aliyuncs.auth.sts.GetSessionAccessKeyRequest)1 GetSessionAccessKeyResponse (com.aliyuncs.auth.sts.GetSessionAccessKeyResponse)1 SingleSendMailRequest (com.aliyuncs.dm.model.v20151123.SingleSendMailRequest)1 ServerException (com.aliyuncs.exceptions.ServerException)1 HttpRequest (com.aliyuncs.http.HttpRequest)1 IClientProfile (com.aliyuncs.profile.IClientProfile)1 PushRequest (com.aliyuncs.push.model.v20160801.PushRequest)1