package com.qnfhq.aliyun;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;

import java.util.Map;

public class AlConfig {

    public static Client createClient(String accessKeyId,String accessKeySecret) throws Exception {
        Config config = new Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret);
        config.endpoint = "dysmsapi.aliyuncs.com";
        return new Client(config);
    }


    /**
     * 获取参数值
     * @param content
     * @param params
     * @return
     */
    public static String getTplParams(String content, Map<String, String> params) {
        for (Map.Entry<String, String> entry : params.entrySet()) {
            content = content.replace("${" + entry.getKey() + "}", entry.getValue());
        }
        return content;
    }

}
