package com.sien.common.sms;

import cn.wecloud.sdk.common.exception.WeCloudApiException;
import cn.wecloud.sdk.sms.client.WeCloudSmsClient;
import cn.wecloud.sdk.sms.data.WeCloudSmsSingleSendResult;
import cn.wecloud.sdk.sms.model.WeCloudSmsAbroadModel;
import cn.wecloud.sdk.sms.request.WeCloudSmsDomesticSingleSendRequest;
import cn.wecloud.sdk.sms.response.WeCloudSmsDomesticSingleSendResponse;


//@Slf4j
public class SmsUtil {

    public static void main(String[] args) throws WeCloudApiException {

        // 创建连接对象
        final WeCloudSmsClient client = new WeCloudSmsClient("9XPgCY9rAb1GG2yg");
        // 创建请求信息对象
        final WeCloudSmsAbroadModel model = new WeCloudSmsAbroadModel("855", "081612642", "1323474417736716290", "888888");
        // 创建请求对象
        final WeCloudSmsDomesticSingleSendRequest request = new WeCloudSmsDomesticSingleSendRequest(model);
        // 执行请求
        final WeCloudSmsDomesticSingleSendResponse execute = client.execute(request);
        // 判断是否请求成功
        if (execute.isSuccess()) {
            // 获取返回业务对象
            final WeCloudSmsSingleSendResult result = execute.getData();
        } else {
            // 输出请求失败信息
//            log.error(execute.getMsg());
        }

    }


    public static void send(String areaCode, String phone, String verificationCode) throws WeCloudApiException {

        // 创建连接对象
        final WeCloudSmsClient client = new WeCloudSmsClient("9XPgCY9rAb1GG2yg");
        // 创建请求信息对象
        String templateId = "1323474417736716290";
        final WeCloudSmsAbroadModel model = new WeCloudSmsAbroadModel(areaCode, phone, templateId, verificationCode);
        // 创建请求对象
        final WeCloudSmsDomesticSingleSendRequest request = new WeCloudSmsDomesticSingleSendRequest(model);
        // 执行请求
        final WeCloudSmsDomesticSingleSendResponse execute = client.execute(request);
        // 判断是否请求成功
        if (execute.isSuccess()) {
            // 获取返回业务对象
            final WeCloudSmsSingleSendResult result = execute.getData();
        } else {
            // 输出请求失败信息
//            log.error(execute.getMsg());
        }

    }
}
