package com.njcn.msgpush.module.push.client.factory.impl;

import com.njcn.msgpush.module.push.client.factory.MessageProviderFactory;
import com.njcn.msgpush.module.push.client.sender.AppPushSender;
import com.njcn.msgpush.module.push.client.sender.EmailSender;
import com.njcn.msgpush.module.push.client.sender.Sender;
import com.njcn.msgpush.module.push.client.sender.SmsSender;
import com.njcn.msgpush.module.push.client.sender.impl.AliyunEmailSender;
import com.njcn.msgpush.module.push.client.sender.impl.AliyunSmsSender;
import com.njcn.msgpush.module.push.client.setting.impl.AliYunMailSetting;
import com.njcn.msgpush.module.push.dal.dataobject.channel.ChannelProviderConfigDO;
import lombok.extern.slf4j.Slf4j;

/**
 * @author caozehui
 * @data 2026-02-11
 */
@Slf4j
public class AliyunProviderFactory implements MessageProviderFactory {


    @Override
    public SmsSender createSmsSender(ChannelProviderConfigDO config, Sender sender) {
        AliYunMailSetting aliYunSmsSetting = AliYunMailSetting.builder()
                .accessKeyId(config.getAppKey())
                .accessKeySecret(config.getAppSecret())
                .regionId("cn-hangzhou")
                .endpoint("dysmsapi.aliyuncs.com")
                .build();
        return new AliyunSmsSender(aliYunSmsSetting, sender);
    }


    @Override
    public EmailSender createEmailSender(ChannelProviderConfigDO config, Sender sender) {
        AliYunMailSetting aliYunSmsSetting = AliYunMailSetting.builder()
                .accessKeyId(config.getAppKey())
                .accessKeySecret(config.getAppSecret())
                .regionId("cn-hangzhou")
                .endpoint("dm.aliyuncs.com")
                .build();
        return new AliyunEmailSender(aliYunSmsSetting, sender);
    }

    @Override
    public AppPushSender createAppPushSender(ChannelProviderConfigDO config, Sender sender) {
        log.error("阿里云暂不支持app推送");
        return null;
    }
}
