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.entity.Sms;
import org.springblade.modules.resource.template.HuaweiSmsTemplate;

/**
 * Author pangqijun
 * Date 2023/5/15
 * Description
 */
public class HuaweiSmsBuilder {
    @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.setSignName(sms.getSignName());
        return new HuaweiSmsTemplate(sms.getApiUrl(), sms.getSender(), smsProperties, bladeRedis);
    }
}
