-
Notifications
You must be signed in to change notification settings - Fork 0
Build/update deps #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7098658
chore: remove code coverage data
fulleni ecfe260
chore(.gitignore): update ignored files and directories
fulleni 226ce7b
chore(deps): add dependency ref for core, email_client, and http_client
fulleni 5e0ce56
docs(README): redesign and update package documentation
fulleni 58fd514
docs(README): remove specific backend service reference
fulleni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,4 @@ | ||
| # See https://www.dartlang.org/guides/libraries/private-files | ||
|
|
||
| # Files and directories created by pub | ||
| .dart_tool/ | ||
| .packages | ||
| build/ | ||
| pubspec.lock | ||
| coverage/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,41 @@ | ||
| # email_sendgrid | ||
| <div align="center"> | ||
| <img src="https://avatars.githubusercontent.com/u/202675624?s=400&u=dc72a2b53e8158956a3b672f8e52e39394b6b610&v=4" alt="Flutter News App Toolkit Logo" width="220"> | ||
| <h1>Email SendGrid</h1> | ||
| <p><strong>A concrete implementation of the `EmailClient` interface using the SendGrid API for the Flutter News App Toolkit.</strong></p> | ||
| </div> | ||
|
|
||
|  | ||
| [](https://pub.dev/packages/very_good_analysis) | ||
| [](https://polyformproject.org/licenses/free-trial/1.0.0) | ||
| <p align="center"> | ||
| <img src="https://img.shields.io/badge/coverage-100%25-green?style=for-the-badge" alt="coverage"> | ||
| <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> | ||
| <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> | ||
| </p> | ||
|
|
||
| A concrete implementation of the `EmailClient` interface that uses the SendGrid API to send transactional emails. | ||
| 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. | ||
|
|
||
| ## Description | ||
| ## ⭐ Feature Showcase: Reliable SendGrid Email Integration | ||
|
|
||
| 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. | ||
| This package offers a comprehensive set of features for integrating with the SendGrid API. | ||
|
|
||
| ## Getting Started | ||
| <details> | ||
| <summary><strong>🧱 Core Functionality</strong></summary> | ||
|
|
||
| Add the dependency to your `pubspec.yaml`: | ||
| ### 🚀 `EmailClient` Implementation | ||
| - **`EmailSendGrid` Class:** A concrete implementation of the `EmailClient` interface, providing a standardized way to send emails via SendGrid. | ||
| - **SendGrid API Integration:** Connects directly to the SendGrid v3 API for sending transactional emails, ensuring reliable delivery. | ||
|
|
||
| ```yaml | ||
| dependencies: | ||
| email_sendgrid: | ||
| git: | ||
| url: https://github.com/flutter-news-app-full-source-code/email-sendgrid.git | ||
| # ref: <specific_tag_or_commit> | ||
| ``` | ||
| ### 🌐 Template-Based Email Sending | ||
| - **`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. | ||
|
|
||
| ## Usage | ||
| ### 🛡️ Integrated Error Handling | ||
| - **`HttpClient` & `HttpException`:** Leverages the `http_client` package for underlying HTTP communication and propagates standardized `HttpException` errors (from `core`), ensuring consistent and predictable error management. | ||
|
|
||
| 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. | ||
| ### 💉 Dependency Injection Ready | ||
| - **`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. | ||
|
|
||
| ```dart | ||
| import 'package:dio/dio.dart'; | ||
| import 'package:email_client/email-client.dart'; | ||
| import 'package:email_sendgrid/email_sendgrid.dart'; | ||
| import 'package:http_client/http_client.dart'; | ||
| import 'package:logging/logging.dart'; | ||
| void main() async { | ||
| // 1. Configure the HttpClient for SendGrid | ||
| final sendGridHttpClient = HttpClient( | ||
| baseUrl: 'https://api.sendgrid.com/v3', | ||
| tokenProvider: () async => 'YOUR_SENDGRID_API_KEY', // Provide your key here | ||
| isWeb: false, // Use false for server-side applications | ||
| ); | ||
| // 2. Instantiate the SendGrid email client | ||
| final EmailClient emailClient = EmailSendGrid( | ||
| httpClient: sendGridHttpClient, | ||
| log: Logger('SendGridClient'), | ||
| ); | ||
| // 3. Use the client to send an email | ||
| try { | ||
| await emailClient.sendTransactionalEmail( | ||
| senderEmail: 'noreply@yourdomain.com', | ||
| recipientEmail: 'recipient@example.com', | ||
| subject: 'Your Subject Here', | ||
| templateId: 'd-your-template-id', | ||
| templateData: {'name': 'World'}, | ||
| ); | ||
| print('Email sent successfully!'); | ||
| } on HttpException catch (e) { | ||
| print('Failed to send email: $e'); | ||
| } | ||
| } | ||
| ``` | ||
| > **💡 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. | ||
| </details> | ||
|
|
||
| ## 🔑 Licensing | ||
|
|
||
| This package is source-available and licensed under the [PolyForm Free Trial 1.0.0](LICENSE). Please review the terms before use. | ||
|
|
||
| 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. | ||
| 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. | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.