|
| 1 | +# ht_email_repository |
| 2 | + |
| 3 | + |
| 4 | +[](https://pub.dev/packages/very_good_analysis) |
| 5 | +[](https://polyformproject.org/licenses/free-trial/1.0.0) |
| 6 | + |
| 7 | +A Dart package providing a repository layer for email operations within the |
| 8 | +Headlines Toolkit ecosystem. |
| 9 | + |
| 10 | +## Description |
| 11 | + |
| 12 | +This package contains the `HtEmailRepository`, which acts as an abstraction |
| 13 | +layer over an `HtEmailClient` implementation (from the `ht_email_client` |
| 14 | +package). Its primary purpose is to provide a clean interface for email-related |
| 15 | +tasks while ensuring consistent error handling according to the project's |
| 16 | +standards (propagating `HtHttpException` subtypes from `ht_shared`). |
| 17 | + |
| 18 | +Currently, it focuses on sending One-Time Password (OTP) emails. |
| 19 | + |
| 20 | +## Getting Started |
| 21 | + |
| 22 | +Add the package to your `pubspec.yaml`: |
| 23 | + |
| 24 | +```yaml |
| 25 | +dependencies: |
| 26 | + ht_email_repository: |
| 27 | + git: |
| 28 | + url: https://github.com/headlines-toolkit/ht-email-repository.git |
| 29 | + # ref: <specific_tag_or_commit> # Optional: Pin to a specific version |
| 30 | +``` |
| 31 | + |
| 32 | +Then, import the library: |
| 33 | + |
| 34 | +```dart |
| 35 | +import 'package:ht_email_repository/ht_email_repository.dart'; |
| 36 | +``` |
| 37 | + |
| 38 | +## Features |
| 39 | + |
| 40 | +* Provides the `HtEmailRepository` class. |
| 41 | +* Offers a `sendOtpEmail` method to facilitate sending OTPs via an injected |
| 42 | + `HtEmailClient`. |
| 43 | + |
| 44 | +## Usage |
| 45 | + |
| 46 | +To use this repository, you need to provide an instance of a concrete |
| 47 | +`HtEmailClient` implementation during instantiation. |
| 48 | + |
| 49 | +```dart |
| 50 | +// Example (assuming you have an HtEmailClient instance named 'myEmailClient') |
| 51 | +final emailRepository = HtEmailRepository(emailClient: myEmailClient); |
| 52 | +
|
| 53 | +// Now you can use the repository methods |
| 54 | +try { |
| 55 | + await emailRepository.sendOtpEmail( |
| 56 | + recipientEmail: '[email protected]', |
| 57 | + otpCode: '123456',**** |
| 58 | + ); |
| 59 | + print('OTP email sent successfully!'); |
| 60 | +} on HtHttpException catch (e) { |
| 61 | + print('Failed to send OTP email: $e'); |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +*(Note: The specific `HtEmailClient` implementation will depend on your project's setup, e.g., using a real email service client or an in-memory version for testing.)* |
| 66 | + |
| 67 | +## License |
| 68 | + |
| 69 | +This package is licensed under the [PolyForm Free Trial](LICENSE). Please review the terms before use. |
0 commit comments