Skip to content

Commit cc5a55b

Browse files
committed
docs: update README with usage and license info
- Added getting started section - Updated features description - Added usage examples - Updated license information
1 parent 3d32a89 commit cc5a55b

File tree

1 file changed

+66
-49
lines changed

1 file changed

+66
-49
lines changed

README.md

Lines changed: 66 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,79 @@
1-
# Ht Email Inmemory
1+
# ht_email_inmemory
22

3-
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
4-
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)
5-
[![License: MIT][license_badge]][license_link]
3+
![coverage: percentage](https://img.shields.io/badge/coverage-100-green)
4+
[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)
5+
[![License: PolyForm Free Trial](https://img.shields.io/badge/License-PolyForm%20Free%20Trial-blue)](https://polyformproject.org/licenses/free-trial/1.0.0)
66

7-
A Very Good Project created by Very Good CLI.
7+
An in-memory implementation of the `HtEmailClient` interface, suitable for testing and development environments where actual email sending is not required.
88

9-
## Installation 💻
9+
## Getting Started
1010

11-
**❗ In order to start using Ht Email Inmemory you must have the [Dart SDK][dart_install_link] installed on your machine.**
11+
Add the dependency to your `pubspec.yaml`:
1212

13-
Install via `dart pub add`:
14-
15-
```sh
16-
dart pub add ht_email_inmemory
13+
```yaml
14+
dependencies:
15+
ht_email_inmemory:
16+
git:
17+
url: https://github.com/headlines-toolkit/ht-email-inmemory.git
18+
# Use a specific ref/tag for stability in production
19+
# ref: some-tag
1720
```
1821

19-
---
20-
21-
## Continuous Integration 🤖
22-
23-
Ht Email Inmemory comes with a built-in [GitHub Actions workflow][github_actions_link] powered by [Very Good Workflows][very_good_workflows_link] but you can also add your preferred CI/CD solution.
24-
25-
Out of the box, on each pull request and push, the CI `formats`, `lints`, and `tests` the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses [Very Good Analysis][very_good_analysis_link] for a strict set of analysis options used by our team. Code coverage is enforced using the [Very Good Workflows][very_good_coverage_link].
26-
27-
---
22+
Then, import the package:
2823

29-
## Running Tests 🧪
30-
31-
To run all unit tests:
32-
33-
```sh
34-
dart pub global activate coverage 1.2.0
35-
dart test --coverage=coverage
36-
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
24+
```dart
25+
import 'package:ht_email_inmemory/ht_email_inmemory.dart';
3726
```
3827

39-
To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov).
28+
## Features
29+
30+
* Provides an `HtEmailInMemoryClient` class that implements the `HtEmailClient` interface.
31+
* Simulates the `sendOtpEmail` operation without sending actual emails.
32+
* Includes basic input validation (e.g., email format) and throws standard `ht_shared` exceptions (`InvalidInputException`) on failure, adhering to the client contract.
33+
* Useful for dependency injection in testing or local development setups.
34+
35+
## Usage
36+
37+
Instantiate the client and use it where an `HtEmailClient` is expected:
38+
39+
```dart
40+
import 'package:ht_email_client/ht_email_client.dart';
41+
import 'package:ht_email_inmemory/ht_email_inmemory.dart';
42+
import 'package:ht_shared/ht_shared.dart'; // For exceptions
43+
44+
void main() async {
45+
// Instantiate the in-memory client
46+
final HtEmailClient emailClient = HtEmailInMemoryClient();
47+
48+
const validEmail = '[email protected]';
49+
const invalidEmail = 'invalid-email';
50+
const otp = '123456';
51+
52+
// Example: Sending an OTP (simulated)
53+
try {
54+
print('Attempting to send OTP to $validEmail...');
55+
await emailClient.sendOtpEmail(recipientEmail: validEmail, otpCode: otp);
56+
print('Successfully simulated sending OTP to $validEmail.');
57+
} on HtHttpException catch (e) {
58+
print('Failed to send OTP to $validEmail: $e');
59+
}
60+
61+
// Example: Attempting with invalid input
62+
try {
63+
print('\nAttempting to send OTP to $invalidEmail...');
64+
await emailClient.sendOtpEmail(recipientEmail: invalidEmail, otpCode: otp);
65+
print('Successfully simulated sending OTP to $invalidEmail.'); // Should not reach here
66+
} on InvalidInputException catch (e) {
67+
// Expected exception for invalid email format
68+
print('Caught expected exception for $invalidEmail: $e');
69+
} on HtHttpException catch (e) {
70+
// Catch other potential standard exceptions
71+
print('Caught unexpected exception for $invalidEmail: $e');
72+
}
73+
}
4074
41-
```sh
42-
# Generate Coverage Report
43-
genhtml coverage/lcov.info -o coverage/
44-
45-
# Open Coverage Report
46-
open coverage/index.html
4775
```
4876

49-
[dart_install_link]: https://dart.dev/get-dart
50-
[github_actions_link]: https://docs.github.com/en/actions/learn-github-actions
51-
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
52-
[license_link]: https://opensource.org/licenses/MIT
53-
[logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only
54-
[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only
55-
[mason_link]: https://github.com/felangel/mason
56-
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
57-
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
58-
[very_good_coverage_link]: https://github.com/marketplace/actions/very-good-coverage
59-
[very_good_ventures_link]: https://verygood.ventures
60-
[very_good_ventures_link_light]: https://verygood.ventures#gh-light-mode-only
61-
[very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only
62-
[very_good_workflows_link]: https://github.com/VeryGoodOpenSource/very_good_workflows
77+
## License
78+
79+
This package is licensed under the [PolyForm Free Trial](LICENSE). Please review the terms before use.

0 commit comments

Comments
 (0)