Skip to content

flutter-news-app-full-source-code/email-repository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

email_repository

coverage: percentage style: very good analysis License: PolyForm Free Trial

A repository that provides an abstraction layer over email operations.

Description

This package contains the EmailRepository, which acts as an abstraction layer over an EmailClient implementation (from the email_client package). Its primary purpose is to provide a clean, business-focused interface for email-related tasks while ensuring consistent error handling.

The repository translates business-specific requests (e.g., "send an OTP") into generic, template-based calls to the underlying EmailClient, decoupling the application's core logic from the specifics of email formatting and delivery.

Getting Started

Add the package to your pubspec.yaml:

dependencies:
  email_repository:
    git:
      url: https://github.com/flutter-news-app-full-source-code/email-repository.git
      # ref: <specific_tag_or_commit> # Optional: Pin to a specific version

Then, import the library:

import 'package:email_repository/email_repository.dart';

Features

  • Provides the EmailRepository class.
  • Offers a sendOtpEmail method that abstracts the process of sending an OTP. It calls the underlying client's sendTransactionalEmail method, passing the required template ID and data.

Usage

To use this repository, you need to provide an instance of a concrete EmailClient implementation during instantiation. The consumer of the repository is responsible for providing the template ID.

// Example (in a service that has access to config)
final emailRepository = EmailRepository(emailClient: myEmailClient);
const otpTemplateId = 'd-123456789'; // This would come from config

// Now you can use the repository methods
try {
  await emailRepository.sendOtpEmail(
    senderEmail: '[email protected]',
    recipientEmail: '[email protected]',
    subject: 'Your One-Time Password',
    otpCode: '123456',
    templateId: otpTemplateId,
  );
  print('OTP email sent successfully!');
} on HttpException catch (e) {
  print('Failed to send OTP email: $e');
}

(Note: The specific EmailClient implementation will depend on your project's setup, e.g., using a real email service client or an in-memory version for testing.)

🔑 Licensing

This package is source-available and licensed under the PolyForm Free Trial 1.0.0. 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 organization.

About

A repository that provides an abstraction layer over email operations.

Resources

License

Stars

Watchers

Forks

Languages