Skip to content

Commit 88b16ec

Browse files
committed
chore: renamed the package
1 parent 610dde2 commit 88b16ec

File tree

9 files changed

+90
-97
lines changed

9 files changed

+90
-97
lines changed

.github/cspell.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/dependabot.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ updates:
1010
schedule:
1111
interval: "weekly"
1212
ignore:
13-
- dependency-name: "ht_*"
13+
- dependency-name: "core"
14+
- dependency-name: "email_client"
15+
- dependency-name: "http_client"

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
# ht_email_sendgrid
1+
# email_sendgrid
22

33
![coverage: percentage](https://img.shields.io/badge/coverage-100-green)
44
[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)
55
[![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 concrete implementation of the `HtEmailClient` interface that uses the SendGrid API to send transactional emails.
7+
A concrete implementation of the `EmailClient` interface that uses the SendGrid API to send transactional emails.
88

99
## Description
1010

11-
This package provides `HtEmailSendGrid`, a class that connects to the SendGrid v3 API to send emails. It is designed to be used with the `ht_email_repository` and `ht_http_client` packages, leveraging the standardized `HtHttpClient` for making HTTP requests and handling errors.
11+
This package provides `EmailSendGrid`, a class that connects to the SendGrid v3 API to send emails. It is designed to be used with the `email_repository` and `http_client` packages, leveraging the standardized `HttpClient` for making HTTP requests and handling errors.
1212

1313
## Getting Started
1414

1515
Add the dependency to your `pubspec.yaml`:
1616

1717
```yaml
1818
dependencies:
19-
ht_email_sendgrid:
19+
email_sendgrid:
2020
git:
21-
url: https://github.com/headlines-toolkit/ht-email-sendgrid.git
21+
url: https://github.com/flutter-news-app-full-source-code/email-sendgrid.git
2222
# ref: <specific_tag_or_commit>
2323
```
2424

2525
## Usage
2626

27-
To use this client, you must first configure an `HtHttpClient` instance with the SendGrid API base URL and an `AuthInterceptor` that provides your SendGrid API key.
27+
To use this client, you must first configure an `HttpClient` instance with the SendGrid API base URL and an `AuthInterceptor` that provides your SendGrid API key.
2828

2929
```dart
3030
import 'package:dio/dio.dart';
31-
import 'package:ht_email_client/ht_email_client.dart';
32-
import 'package:ht_email_sendgrid/ht_email_sendgrid.dart';
33-
import 'package:ht_http_client/ht_http_client.dart';
31+
import 'package:email_client/email-client.dart';
32+
import 'package:email_sendgrid/email_sendgrid.dart';
33+
import 'package:http_client/http_client.dart';
3434
import 'package:logging/logging.dart';
3535
3636
void main() async {
37-
// 1. Configure the HtHttpClient for SendGrid
38-
final sendGridHttpClient = HtHttpClient(
37+
// 1. Configure the HttpClient for SendGrid
38+
final sendGridHttpClient = HttpClient(
3939
baseUrl: 'https://api.sendgrid.com/v3',
4040
tokenProvider: () async => 'YOUR_SENDGRID_API_KEY', // Provide your key here
4141
isWeb: false, // Use false for server-side applications
4242
);
4343
4444
// 2. Instantiate the SendGrid email client
45-
final HtEmailClient emailClient = HtEmailSendGrid(
45+
final EmailClient emailClient = EmailSendGrid(
4646
httpClient: sendGridHttpClient,
4747
log: Logger('SendGridClient'),
4848
);
@@ -56,12 +56,15 @@ void main() async {
5656
templateData: {'name': 'World'},
5757
);
5858
print('Email sent successfully!');
59-
} on HtHttpException catch (e) {
59+
} on HttpException catch (e) {
6060
print('Failed to send email: $e');
6161
}
6262
}
6363
```
6464

65-
## License
6665

67-
This package is licensed under the [PolyForm Free Trial](LICENSE). Please review the terms before use.
66+
## 🔑 Licensing
67+
68+
This package is source-available and licensed under the [PolyForm Free Trial 1.0.0](LICENSE). Please review the terms before use.
69+
70+
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**](https://github.com/flutter-news-app-full-source-code) organization.

coverage/lcov.info

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
SF:lib\src\email_sendgrid.dart
2+
DA:21,1
3+
DA:30,1
4+
DA:37,2
5+
DA:38,1
6+
DA:42,1
7+
DA:43,1
8+
DA:44,1
9+
DA:45,1
10+
DA:46,1
11+
DA:51,1
12+
DA:58,2
13+
DA:59,2
14+
DA:60,1
15+
DA:62,1
16+
DA:68,0
17+
DA:73,0
18+
LF:16
19+
LH:14
20+
end_of_record

lib/email_sendgrid.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// A concrete implementation of the EmailClient interface that uses the
2+
/// SendGrid API to send transactional emails.
3+
library;
4+
5+
export 'src/email_sendgrid.dart';

lib/ht_email_sendgrid.dart

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/src/ht_email_sendgrid.dart renamed to lib/src/email_sendgrid.dart

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import 'package:ht_email_client/ht_email_client.dart';
2-
import 'package:ht_http_client/ht_http_client.dart';
3-
import 'package:ht_shared/ht_shared.dart';
1+
// ignore_for_file: lines_longer_than_80_chars
2+
3+
import 'package:core/core.dart';
4+
import 'package:email_client/email_client.dart' show EmailClient;
5+
import 'package:http_client/http_client.dart';
46
import 'package:logging/logging.dart';
57

6-
/// {@template ht_email_sendgrid}
8+
/// {@template email_sendgrid}
79
/// A client for sending emails using the SendGrid API.
810
///
9-
/// This class implements the [HtEmailClient] interface and uses an
10-
/// [HtHttpClient] to communicate with the SendGrid v3 API.
11+
/// This class implements the [EmailClient] interface and uses an
12+
/// [HttpClient] to communicate with the SendGrid v3 API.
1113
/// {@endtemplate}
12-
class HtEmailSendGrid implements HtEmailClient {
13-
/// {@macro ht_email_sendgrid}
14+
class EmailSendGrid implements EmailClient {
15+
/// {@macro email_sendgrid}
1416
///
15-
/// Requires a pre-configured [HtHttpClient] instance that includes the
17+
/// Requires a pre-configured [HttpClient] instance that includes the
1618
/// SendGrid API base URL ('https://api.sendgrid.com/v3') and an
1719
/// authentication interceptor to provide the SendGrid API key as a
1820
/// Bearer token.
19-
const HtEmailSendGrid({
20-
required HtHttpClient httpClient,
21-
required Logger log,
22-
}) : _httpClient = httpClient,
23-
_log = log;
21+
const EmailSendGrid({required HttpClient httpClient, required Logger log})
22+
: _httpClient = httpClient,
23+
_log = log;
2424

25-
final HtHttpClient _httpClient;
25+
final HttpClient _httpClient;
2626
final Logger _log;
2727

2828
static const String _sendPath = '/mail/send';
@@ -53,13 +53,13 @@ class HtEmailSendGrid implements HtEmailClient {
5353
};
5454

5555
try {
56-
// The HtHttpClient's post method will handle the request and its
57-
// ErrorInterceptor will map DioExceptions to HtHttpExceptions.
56+
// The HttpClient's post method will handle the request and its
57+
// ErrorInterceptor will map DioExceptions to HttpExceptions.
5858
await _httpClient.post<void>(_sendPath, data: payload);
5959
_log.info(
6060
'Successfully requested email send to $recipientEmail with template $templateId',
6161
);
62-
} on HtHttpException {
62+
} on HttpException {
6363
// Re-throw the already mapped exception for the repository/service
6464
// layer to handle.
6565
rethrow;
@@ -70,9 +70,7 @@ class HtEmailSendGrid implements HtEmailClient {
7070
e,
7171
s,
7272
);
73-
throw OperationFailedException(
74-
'An unexpected error occurred: $e',
75-
);
73+
throw OperationFailedException('An unexpected error occurred: $e');
7674
}
7775
}
7876
}

pubspec.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
name: ht_email_sendgrid
2-
description: A concrete implementation of the HtEmailClient interface that uses the SendGrid API to send transactional emails.
3-
repository: https://github.com/headlines-toolkit/ht-email-sendgrid
1+
name: email_sendgrid
2+
description: A concrete implementation of the EmailClient interface that uses the SendGrid API to send transactional emails.
3+
repository: https://github.com/flutter-news-app-full-source-code/email-sendgrid
44
publish_to: none
55

66
environment:
77
sdk: ^3.8.0
88

99
dependencies:
1010
dio: ^5.8.0+1
11-
ht_email_client:
11+
email_client:
1212
git:
13-
url: https://github.com/headlines-toolkit/ht-email-client.git
14-
ht_http_client:
13+
url: https://github.com/flutter-news-app-full-source-code/email-client.git
14+
http_client:
1515
git:
16-
url: https://github.com/headlines-toolkit/ht-http-client.git
17-
ht_shared:
16+
url: https://github.com/flutter-news-app-full-source-code/http-client.git
17+
core:
1818
git:
19-
url: https://github.com/headlines-toolkit/ht-shared.git
19+
url: https://github.com/flutter-news-app-full-source-code/core.git
2020
logging: ^1.3.0
2121

2222
dev_dependencies:

test/src/ht_email_sendgrid_test.dart renamed to test/src/email_sendgrid_test.dart

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
// ignore_for_file: avoid_dynamic_calls
1+
// ignore_for_file: avoid_dynamic_calls, inference_failure_on_function_invocation
22

3-
import 'package:ht_email_sendgrid/ht_email_sendgrid.dart';
4-
import 'package:ht_http_client/ht_http_client.dart';
5-
import 'package:ht_shared/ht_shared.dart';
3+
import 'package:core/core.dart';
4+
import 'package:email_sendgrid/email_sendgrid.dart';
5+
import 'package:http_client/http_client.dart';
66
import 'package:logging/logging.dart';
77
import 'package:mocktail/mocktail.dart';
88
import 'package:test/test.dart';
99

10-
class MockHtHttpClient extends Mock implements HtHttpClient {}
10+
class MockHttpClient extends Mock implements HttpClient {}
1111

1212
void main() {
13-
group('HtEmailSendGrid', () {
14-
late HtHttpClient mockHttpClient;
15-
late HtEmailSendGrid emailClient;
13+
group('EmailSendGrid', () {
14+
late HttpClient mockHttpClient;
15+
late EmailSendGrid emailClient;
1616

1717
const senderEmail = 'sender@example.com';
1818
const recipientEmail = 'test@example.com';
1919
const templateId = 'd-12345';
2020
const templateData = {'name': 'Test User'};
2121

2222
setUp(() {
23-
mockHttpClient = MockHtHttpClient();
24-
emailClient = HtEmailSendGrid(
23+
mockHttpClient = MockHttpClient();
24+
emailClient = EmailSendGrid(
2525
httpClient: mockHttpClient,
2626
log: Logger('TestLogger'),
2727
);
@@ -35,10 +35,7 @@ void main() {
3535
test('calls http client post with correct payload on success', () async {
3636
// Arrange
3737
when(
38-
() => mockHttpClient.post<void>(
39-
any(),
40-
data: any(named: 'data'),
41-
),
38+
() => mockHttpClient.post<void>(any(), data: any(named: 'data')),
4239
).thenAnswer((_) async => Future.value());
4340

4441
// Act
@@ -63,20 +60,14 @@ void main() {
6360
final personalizations =
6461
payload['personalizations'] as List<Map<String, dynamic>>;
6562
expect(personalizations.first['to'].first['email'], recipientEmail);
66-
expect(
67-
personalizations.first['dynamic_template_data'],
68-
templateData,
69-
);
63+
expect(personalizations.first['dynamic_template_data'], templateData);
7064
});
7165

72-
test('propagates HtHttpException from http client', () async {
66+
test('propagates HttpException from http client', () async {
7367
// Arrange
74-
final exception = ServerException('Failed');
68+
const exception = ServerException('Failed');
7569
when(
76-
() => mockHttpClient.post<void>(
77-
any(),
78-
data: any(named: 'data'),
79-
),
70+
() => mockHttpClient.post<void>(any(), data: any(named: 'data')),
8071
).thenThrow(exception);
8172

8273
// Act & Assert
@@ -87,7 +78,7 @@ void main() {
8778
templateId: templateId,
8879
templateData: templateData,
8980
),
90-
throwsA(isA<HtHttpException>()),
81+
throwsA(isA<HttpException>()),
9182
);
9283
});
9384
});

0 commit comments

Comments
 (0)