import org.springframework.context.annotation.*;
import com.broadleafcommerce.notification.service.*;
import com.broadleafcommerce.notification.service.integration.SendGridMessageSender;
import com.sendgrid.Email;
@Configuration
public class MyNotificationConfiguration {
// Step 1: Configure a SendGridMessageSender
@Bean
SendGridMessageSender sendGridMessageSender() {
// Obtain an apiKey from SendGrid
String apiKey = "yourAPIKey";
Email senderEmail = new Email("sender@yourcompany.com", "Sender Name");
// Initialize the SendGridSender
return new SendGridMessageSender(apiKey,senderEmail);
}
// Step 2: Register an EMAIL handler with the NotificationService
@Bean
NotificationHandler emailNotificationHandler(ThymeleafMessageBuilder builder,
SendGridMessageSender sender) {
return new DefaultNotificationHandler(builder, sender);
}
}