package com.storlead.sales.mail.connection;

/**
 * @program: sp-sales-platform
 * @description:
 * @author: chenkq
 * @create: 2024-05-30 14:56
 */
public abstract class MailConnectionFactory {
    public abstract MailConnection createConnection();

    public static MailConnectionFactory getFactory(String protocol, String host, String port, String user, String password) {
        switch (protocol.toLowerCase()) {
            case "imap":
                return new IMAPConnectionFactory(host, port, user, password);
            case "pop3":
                return new POP3ConnectionFactory(host, port, user, password);
            default:
                throw new IllegalArgumentException("Unsupported protocol: " + protocol);
        }
    }

    public static SMTPConnectionFactory getSMTPFactory(String host, String port, String user, String password) {
        return new SMTPConnectionFactory(host, port, user, password);
    }
}
