@@ -11,11 +11,13 @@ Headlines Toolkit ecosystem.
1111
1212This package contains the ` HtEmailRepository ` , which acts as an abstraction
1313layer 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 ` ).
14+ package). Its primary purpose is to provide a clean, business-focused interface
15+ for email-related tasks while ensuring consistent error handling.
1716
18- Currently, it focuses on sending One-Time Password (OTP) emails.
17+ The repository translates business-specific requests (e.g., "send an OTP")
18+ into generic, template-based calls to the underlying ` HtEmailClient ` ,
19+ decoupling the application's core logic from the specifics of email
20+ formatting and delivery.
1921
2022## Getting Started
2123
@@ -38,23 +40,27 @@ import 'package:ht_email_repository/ht_email_repository.dart';
3840## Features
3941
4042* Provides the ` HtEmailRepository ` class.
41- * Offers a ` sendOtpEmail ` method to facilitate sending OTPs via an injected
42- ` HtEmailClient ` .
43+ * Offers a ` sendOtpEmail ` method that abstracts the process of sending an
44+ OTP. It calls the underlying client's ` sendTransactionalEmail ` method,
45+ passing the required template ID and data.
4346
4447## Usage
4548
4649To use this repository, you need to provide an instance of a concrete
47- ` HtEmailClient ` implementation during instantiation.
50+ ` HtEmailClient ` implementation during instantiation. The consumer of the
51+ repository is responsible for providing the template ID.
4852
4953``` dart
50- // Example (assuming you have an HtEmailClient instance named 'myEmailClient' )
54+ // Example (in a service that has access to config )
5155final emailRepository = HtEmailRepository(emailClient: myEmailClient);
56+ const otpTemplateId = 'd-123456789'; // This would come from config
5257
5358// Now you can use the repository methods
5459try {
5560 await emailRepository.sendOtpEmail(
5661 recipientEmail: '[email protected] ', 57- otpCode: '123456',****
62+ otpCode: '123456',
63+ templateId: otpTemplateId,
5864 );
5965 print('OTP email sent successfully!');
6066} on HtHttpException catch (e) {
0 commit comments