package org.springblade.modules.resource.builder.sms;

import lombok.SneakyThrows;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.sms.SmsTemplate;
import org.springblade.core.sms.props.SmsProperties;
import org.springblade.modules.resource.builder.sms.client.HwClient;
import org.springblade.modules.resource.entity.Sms;
import org.springblade.modules.resource.template.HwSmsTemplate;

/**
 * @author: lianghanqiang
 * @description: 华为云短信构建类
	* @since: 8/25/21 -- 3:53 PM
	*/
public class HwSmsBuilder {

	@SneakyThrows
	public static SmsTemplate template(Sms sms, BladeRedis bladeRedis) {
		SmsProperties smsProperties = new SmsProperties();
		smsProperties.setTemplateId(sms.getTemplateId());
		smsProperties.setAccessKey(sms.getAccessKey());
		smsProperties.setSecretKey(sms.getSecretKey());
		smsProperties.setRegionId(sms.getRemark());
		smsProperties.setSignName(sms.getSignName());
		HwClient hwClient = new HwClient(smsProperties);
		return new HwSmsTemplate(hwClient,bladeRedis);
	}
}
