diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9093b6..9567aee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,22 @@ name: CI on: push: branches: [develop] + paths-ignore: + - '**.md' + - 'docs/**' + - 'tutorials/**' + - 'examples/**/README.md' + - 'LICENSE' + - '.gitignore' pull_request: branches: [develop, main] + paths-ignore: + - '**.md' + - 'docs/**' + - 'tutorials/**' + - 'examples/**/README.md' + - 'LICENSE' + - '.gitignore' workflow_dispatch: inputs: triggered-by: @@ -13,10 +27,5 @@ on: jobs: build: uses: fireflyframework/.github/.github/workflows/java-ci.yml@main - permissions: - packages: read - contents: read - actions: write with: java-version: '25' - secrets: inherit diff --git a/README.md b/README.md index 3a888ae..f0cd676 100644 --- a/README.md +++ b/README.md @@ -1,160 +1,92 @@ -# fireflyframework-notifications-sendgrid +# Firefly Framework - Notifications - SendGrid [![CI](https://github.com/fireflyframework/fireflyframework-notifications-sendgrid/actions/workflows/ci.yml/badge.svg)](https://github.com/fireflyframework/fireflyframework-notifications-sendgrid/actions/workflows/ci.yml) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) +[![Java](https://img.shields.io/badge/Java-21%2B-orange.svg)](https://openjdk.org) +[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.x-green.svg)](https://spring.io/projects/spring-boot) -SendGrid email adapter for Firefly Notifications Library. +> SendGrid email adapter for Firefly Notifications. -## Overview - -This module is an **infrastructure adapter** in the hexagonal architecture that implements the `EmailProvider` port interface. It handles all SendGrid-specific integration details, including API authentication, request transformation, and error handling. +--- -### Architecture Role +## Table of Contents -``` -Application Layer (EmailService) - ↓ depends on -Domain Layer (EmailProvider interface) - ↑ implemented by -Infrastructure Layer (SendGridEmailProvider) ← THIS MODULE - ↓ calls -SendGrid REST API -``` +- [Overview](#overview) +- [Features](#features) +- [Requirements](#requirements) +- [Installation](#installation) +- [Quick Start](#quick-start) +- [Configuration](#configuration) +- [Documentation](#documentation) +- [Contributing](#contributing) +- [License](#license) -This adapter can be swapped with other email providers (Resend, AWS SES) without changing your application code. +## Overview -## Installation +Firefly Framework Notifications SendGrid implements the `EmailProvider` interface from the Firefly Notifications core module using SendGrid as the delivery provider. It provides `SendGridEmailProvider` which handles email delivery through the SendGrid API. -Add this dependency to your `pom.xml`: +The module includes auto-configuration for seamless activation when included on the classpath alongside the notifications core module. Configuration properties allow customizing API credentials and provider-specific settings. -```xml path=null start=null - - org.fireflyframework - fireflyframework-notifications-core - 1.0.0-SNAPSHOT - +## Features - - org.fireflyframework - fireflyframework-notifications-sendgrid - 1.0.0-SNAPSHOT - -``` +- `EmailProvider` implementation using SendGrid +- Spring Boot auto-configuration for seamless activation +- Configurable API credentials via application properties +- Standalone provider library (include alongside fireflyframework-notifications) -## Configuration +## Requirements -Add the following to your `application.yml`: +- Java 21+ +- Spring Boot 3.x +- Maven 3.9+ +- SendGrid account and API credentials -```yaml path=null start=null -notifications: - email: - provider: sendgrid # Enables this adapter +## Installation -sendgrid: - api-key: ${SENDGRID_API_KEY} # Your SendGrid API key +```xml + + org.fireflyframework + fireflyframework-notifications-sendgrid + 26.01.01 + ``` -### Getting Your API Key - -1. Sign up at [sendgrid.com](https://sendgrid.com) -2. Navigate to Settings → API Keys -3. Create a new API key with "Mail Send" permissions -4. Set it as an environment variable: - ```bash - export SENDGRID_API_KEY="SG.your-key-here" - ``` - -## Usage - -Inject `EmailService` from the core library. Spring automatically wires this adapter: - -```java path=null start=null -@Service -public class NotificationService { - - @Autowired - private EmailService emailService; - - public void sendWelcomeEmail(String recipient) { - EmailRequestDTO request = EmailRequestDTO.builder() - .from("noreply@example.com") - .to(List.of(recipient)) - .subject("Welcome!") - .html("

Welcome to our platform

") - .text("Welcome to our platform") - .build(); - - emailService.sendEmail(request) - .subscribe(response -> { - if (response.isSuccess()) { - log.info("Email sent: {}", response.getMessageId()); - } else { - log.error("Failed: {}", response.getError()); - } - }); - } -} +## Quick Start + +```xml + + + org.fireflyframework + fireflyframework-notifications + + + org.fireflyframework + fireflyframework-notifications-sendgrid + + ``` -## Features +## Configuration -- **HTML and plain text** emails -- **CC and BCC** recipients -- **File attachments** with automatic base64 encoding -- **Reactive** - returns `Mono` -- **Error handling** - Graceful degradation with error messages - -### Sending with Attachments - -```java path=null start=null -EmailAttachmentDTO attachment = EmailAttachmentDTO.builder() - .filename("report.pdf") - .content(pdfBytes) - .contentType("application/pdf") - .build(); - -EmailRequestDTO request = EmailRequestDTO.builder() - .from("reports@example.com") - .to(List.of("user@example.com")) - .subject("Monthly Report") - .html("

See attached report

") - .attachments(List.of(attachment)) - .build(); - -emailService.sendEmail(request).subscribe(); +```yaml +firefly: + notifications: + sendgrid: + api-key: SG.xxxxxxxxxx + from-email: noreply@example.com + from-name: My Application ``` -## Switching Providers - -To switch from SendGrid to another provider (e.g., Resend): - -1. Remove this dependency from `pom.xml` -2. Add `fireflyframework-notifications-resend` dependency -3. Update configuration to use `provider: resend` - -**No code changes required** in your services—that's the power of hexagonal architecture! - -## Implementation Details - -This adapter: -- Implements `EmailProvider` interface from `fireflyframework-notifications-core` -- Uses SendGrid Java SDK for API calls -- Transforms generic `EmailRequestDTO` to SendGrid's `Mail` object -- Handles authentication via API key -- Returns standardized `EmailResponseDTO` - -## Troubleshooting +## Documentation -### Error: "No qualifying bean of type 'EmailProvider'" +No additional documentation available for this project. -- Ensure `notifications.email.provider=sendgrid` is set -- Verify `sendgrid.api-key` is configured +## Contributing -### Error: "Unauthorized" +Contributions are welcome. Please read the [CONTRIBUTING.md](CONTRIBUTING.md) guide for details on our code of conduct, development process, and how to submit pull requests. -- Check your API key is valid -- Verify the key has "Mail Send" permissions +## License -## References +Copyright 2024-2026 Firefly Software Solutions Inc. -- [SendGrid API Documentation](https://docs.sendgrid.com/api-reference/mail-send/mail-send) -- [Firefly Notifications Architecture](../fireflyframework-notifications/ARCHITECTURE.md) +Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.