Skip to content

Commit c5e36d0

Browse files
authored
Merge pull request #4 from flutter-news-app-full-source-code/build/update-deps
Build/update deps
2 parents 422f8c6 + bf7ca28 commit c5e36d0

File tree

5 files changed

+481
-81
lines changed

5 files changed

+481
-81
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# See https://www.dartlang.org/guides/libraries/private-files
2-
3-
# Files and directories created by pub
41
.dart_tool/
52
.packages
63
build/
7-
pubspec.lock
4+
coverage/

README.md

Lines changed: 25 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,38 @@
1-
# email_client
1+
<div align="center">
2+
<img src="https://avatars.githubusercontent.com/u/202675624?s=400&u=dc72a2b53e8158956a3b672f8e52e39394b6b610&v=4" alt="Flutter News App Toolkit Logo" width="220">
3+
<h1>Email Client</h1>
4+
<p><strong>An abstract interface for sending emails within the Flutter News App Toolkit.</strong></p>
5+
</div>
26

3-
![coverage: percentage](https://img.shields.io/badge/coverage-XX-green)
4-
[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)
5-
[![License: PolyForm Free Trial](https://img.shields.io/badge/License-PolyForm%20Free%20Trial-blue)](https://polyformproject.org/licenses/free-trial/1.0.0)
7+
<p align="center">
8+
<img src="https://img.shields.io/badge/coverage-100%25-green?style=for-the-badge" alt="coverage">
9+
<a href="https://flutter-news-app-full-source-code.github.io/docs/"><img src="https://img.shields.io/badge/LIVE_DOCS-VIEW-slategray?style=for-the-badge" alt="Live Docs: View"></a>
10+
<a href="https://github.com/flutter-news-app-full-source-code"><img src="https://img.shields.io/badge/MAIN_PROJECT-BROWSE-purple?style=for-the-badge" alt="Main Project: Browse"></a>
11+
</p>
612

7-
This package provides the contract (`EmailClient`) that concrete implementations (e.g., SMTP, AWS SES, SendGrid clients) should adhere to.
13+
This `email_client` package defines the abstract interface (`EmailClient`) for sending emails within the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). It establishes a clear contract that concrete implementations (e.g., using SMTP, AWS SES, SendGrid) should adhere to. This approach decouples application logic from specific email service providers and email content/styling, which can be managed directly within your chosen email service. This package is crucial for backend services (like a Dart Frog API) that require robust and flexible email dispatch capabilities.
814

9-
## Getting Started
15+
## ⭐ Feature Showcase: Flexible & Provider-Agnostic Email Dispatch
1016

11-
To use this package in your Dart backend project (like Dart Frog), add it to your `pubspec.yaml` file:
17+
This package offers a comprehensive set of features for managing email sending operations.
1218

13-
```yaml
14-
dependencies:
15-
email_client:
16-
git:
17-
url: https://github.com/flutter-news-app-full-source-code/email-client.git
18-
# Use a specific ref/tag for stability in production
19-
# ref: main
20-
```
19+
<details>
20+
<summary><strong>🧱 Core Functionality</strong></summary>
2121

22-
Then run `dart pub get`.
22+
### 🚀 Abstract `EmailClient` Interface
23+
- **`EmailClient` Abstract Class:** Defines a generic, provider-agnostic interface for sending transactional emails. This decouples application logic from specific email service providers.
24+
- **`sendTransactionalEmail` Method:** Provides a method for sending emails using pre-defined templates, requiring `senderEmail`, `recipientEmail`, `subject`, `templateId`, and `templateData`. This allows email content and styling to be managed directly within the email service provider.
2325

24-
## Features
26+
### 🛡️ Standardized Error Handling
27+
- **`HttpException` Propagation:** Implementations are expected to handle underlying service errors and map them to standard `HttpException` subtypes (from `core`), ensuring consistent error management across the application layers.
2528

26-
* **`EmailClient` Abstract Class:** Defines a generic, provider-agnostic interface for sending transactional emails. This approach decouples application logic from email content and styling, which can be managed directly within your email service provider (e.g., SendGrid, AWS SES).
27-
* `Future<void> sendTransactionalEmail({required String senderEmail, required String recipientEmail, required String subject, required String templateId, required Map<String, dynamic> templateData})`: Sends an email using a pre-defined template. Implementations must handle underlying service errors and map them to standard `core` exceptions.
29+
### 💉 Implementation Agnostic
30+
- **Interchangeable Implementations:** Designed to be implemented by various email service providers (e.g., SendGrid, AWS SES, local SMTP), allowing developers to swap email solutions without altering core application logic.
2831

29-
## Usage
30-
31-
This package only provides the abstract interface. You need a concrete implementation package (e.g., `ht_email_sendgrid`) that implements `EmailClient`.
32-
33-
In your backend application (e.g., Dart Frog), you would typically:
34-
35-
1. Depend on a concrete implementation package.
36-
2. Configure and provide an instance of the concrete client using dependency injection.
37-
3. Inject `EmailClient` into your services where email sending is required.
38-
39-
```dart
40-
// Example (Conceptual - in a service or route handler)
41-
import 'package:email_client/email_client.dart';
42-
import 'package:core/core.dart';
43-
44-
class AuthService {
45-
const AuthService({required EmailClient emailClient})
46-
: _emailClient = emailClient;
47-
48-
final EmailClient _emailClient;
49-
50-
Future<void> sendVerificationEmail(String email, String otp) async {
51-
try {
52-
// Use the generic method to send an email via a template.
53-
// The template ID and data structure are managed by the email provider.
54-
await _emailClient.sendTransactionalEmail(
55-
senderEmail: '[email protected]',
56-
recipientEmail: email,
57-
subject: 'Your Verification Code',
58-
templateId: 'd-1234567890abcdef1234567890abcdef', // Example SendGrid Template ID
59-
templateData: {
60-
'otp_code': otp,
61-
'username': 'Valued User',
62-
},
63-
);
64-
// Handle success
65-
} on HttpException {
66-
// Handle specific email sending errors (e.g., log, return error response)
67-
rethrow;
68-
}
69-
}
70-
}
71-
```
32+
> **💡 Your Advantage:** This package provides a clear, abstract interface for email sending, decoupling your application from specific email service providers. This design promotes flexibility, testability, and maintainability, allowing you to easily integrate and swap email solutions as needed.
7233
34+
</details>
7335

7436
## 🔑 Licensing
7537

76-
This package is source-available and licensed under the [PolyForm Free Trial 1.0.0](LICENSE). Please review the terms before use.
77-
78-
For commercial licensing options that grant the right to build and distribute unlimited applications, please visit the main [**Flutter News App - Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code) organization.
38+
This `email_client` package is an integral part of the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). For comprehensive details regarding licensing, including trial and commercial options for the entire toolkit, please refer to the main toolkit organization page.

0 commit comments

Comments
 (0)