Skip to content

Commit 4cd256b

Browse files
authored
Merge pull request #2 from flutter-news-app-full-source-code/build/update-deps
Build/update deps
2 parents 80606a9 + 58fd514 commit 4cd256b

File tree

5 files changed

+520
-82
lines changed

5 files changed

+520
-82
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: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,41 @@
1-
# email_sendgrid
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 SendGrid</h1>
4+
<p><strong>A concrete implementation of the `EmailClient` interface using the SendGrid API for the Flutter News App Toolkit.</strong></p>
5+
</div>
26

3-
![coverage: percentage](https://img.shields.io/badge/coverage-100-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-
A concrete implementation of the `EmailClient` interface that uses the SendGrid API to send transactional emails.
13+
This `email_sendgrid` package provides a concrete implementation of the `EmailClient` interface within the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). It leverages the SendGrid v3 API to send transactional emails, offering a robust and reliable solution for email dispatch. Designed to be used with the `email_repository` and `http_client` packages, it utilizes the standardized `HttpClient` for making HTTP requests and handling errors, ensuring consistent behavior and robust error management. This package is crucial for backend services that require integration with a powerful email service provider.
814

9-
## Description
15+
## ⭐ Feature Showcase: Reliable SendGrid Email Integration
1016

11-
This package provides `EmailSendGrid`, a class that connects to the SendGrid v3 API to send emails. It is designed to be used with the `email_repository` and `http_client` packages, leveraging the standardized `HttpClient` for making HTTP requests and handling errors.
17+
This package offers a comprehensive set of features for integrating with the SendGrid API.
1218

13-
## Getting Started
19+
<details>
20+
<summary><strong>🧱 Core Functionality</strong></summary>
1421

15-
Add the dependency to your `pubspec.yaml`:
22+
### 🚀 `EmailClient` Implementation
23+
- **`EmailSendGrid` Class:** A concrete implementation of the `EmailClient` interface, providing a standardized way to send emails via SendGrid.
24+
- **SendGrid API Integration:** Connects directly to the SendGrid v3 API for sending transactional emails, ensuring reliable delivery.
1625

17-
```yaml
18-
dependencies:
19-
email_sendgrid:
20-
git:
21-
url: https://github.com/flutter-news-app-full-source-code/email-sendgrid.git
22-
# ref: <specific_tag_or_commit>
23-
```
26+
### 🌐 Template-Based Email Sending
27+
- **`sendTransactionalEmail` Method:** Supports sending emails using pre-defined SendGrid templates, allowing for dynamic content injection via `templateData`. This decouples email content and styling from application logic.
2428

25-
## Usage
29+
### 🛡️ Integrated Error Handling
30+
- **`HttpClient` & `HttpException`:** Leverages the `http_client` package for underlying HTTP communication and propagates standardized `HttpException` errors (from `core`), ensuring consistent and predictable error management.
2631

27-
To use this client, you must first configure an `HttpClient` instance with the SendGrid API base URL and an `AuthInterceptor` that provides your SendGrid API key.
32+
### 💉 Dependency Injection Ready
33+
- **`HttpClient` Dependency:** Requires an instance of `HttpClient` (from the `http_client` package) configured with the SendGrid API base URL and API key, promoting loose coupling and testability.
2834

29-
```dart
30-
import 'package:dio/dio.dart';
31-
import 'package:email_client/email-client.dart';
32-
import 'package:email_sendgrid/email_sendgrid.dart';
33-
import 'package:http_client/http_client.dart';
34-
import 'package:logging/logging.dart';
35-
36-
void main() async {
37-
// 1. Configure the HttpClient for SendGrid
38-
final sendGridHttpClient = HttpClient(
39-
baseUrl: 'https://api.sendgrid.com/v3',
40-
tokenProvider: () async => 'YOUR_SENDGRID_API_KEY', // Provide your key here
41-
isWeb: false, // Use false for server-side applications
42-
);
43-
44-
// 2. Instantiate the SendGrid email client
45-
final EmailClient emailClient = EmailSendGrid(
46-
httpClient: sendGridHttpClient,
47-
log: Logger('SendGridClient'),
48-
);
49-
50-
// 3. Use the client to send an email
51-
try {
52-
await emailClient.sendTransactionalEmail(
53-
senderEmail: '[email protected]',
54-
recipientEmail: '[email protected]',
55-
subject: 'Your Subject Here',
56-
templateId: 'd-your-template-id',
57-
templateData: {'name': 'World'},
58-
);
59-
print('Email sent successfully!');
60-
} on HttpException catch (e) {
61-
print('Failed to send email: $e');
62-
}
63-
}
64-
```
35+
> **💡 Your Advantage:** This package provides a robust and production-ready SendGrid integration for your email sending needs. It simplifies the process of sending transactional emails, leverages standardized error handling, and integrates seamlessly with the existing `http_client` and `email_client` architecture.
6536
37+
</details>
6638

6739
## 🔑 Licensing
6840

69-
This package is source-available and licensed under the [PolyForm Free Trial 1.0.0](LICENSE). Please review the terms before use.
70-
71-
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.
41+
This `email_sendgrid` 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.

coverage/lcov.info

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)