@@ -17,25 +17,33 @@ class HtEmailRepository {
17
17
18
18
final HtEmailClient _emailClient;
19
19
20
- /// Sends a One-Time Password (OTP) email via the email client.
20
+ /// Sends a One-Time Password (OTP) email by calling the underlying client.
21
21
///
22
- /// Delegates the call to the injected [HtEmailClient] .
22
+ /// This method abstracts the specific details of sending an OTP email. It
23
+ /// constructs the required `templateData` and calls the generic
24
+ /// `sendTransactionalEmail` method on the injected [HtEmailClient] .
23
25
///
24
- /// Throws [HtHttpException] subtypes on failure, as propagated
25
- /// from the client.
26
+ /// - [recipientEmail] : The email address of the recipient.
27
+ /// - [otpCode] : The One-Time Password to be sent.
28
+ /// - [templateId] : The ID of the transactional email template to use.
29
+ ///
30
+ /// Throws [HtHttpException] subtypes on failure, as propagated from the
31
+ /// client.
26
32
Future <void > sendOtpEmail ({
27
33
required String recipientEmail,
28
34
required String otpCode,
35
+ required String templateId,
29
36
}) async {
30
37
try {
31
- await _emailClient.sendOtpEmail (
38
+ await _emailClient.sendTransactionalEmail (
32
39
recipientEmail: recipientEmail,
33
- otpCode: otpCode,
40
+ templateId: templateId,
41
+ templateData: {
42
+ 'otp_code' : otpCode,
43
+ },
34
44
);
35
45
} on HtHttpException {
36
46
rethrow ; // Propagate client-level exceptions
37
47
}
38
- // Catch-all for unexpected errors is generally avoided here,
39
- // relying on the client's defined exceptions.
40
48
}
41
49
}
0 commit comments