Skip to content

Commit 902d265

Browse files
authored
Merge pull request #14 from PandaTechAM/development
Nuget updates
2 parents 5151ff6 + 206df48 commit 902d265

File tree

6 files changed

+99
-114
lines changed

6 files changed

+99
-114
lines changed

Readme.md

Lines changed: 83 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,34 @@
1-
# 1. PandaTech.Communicator
2-
3-
- [1. EasyRateLimiter](#1-easyratelimiter)
4-
- [1.1. Introduction](#11-introduction)
5-
- [1.2. Installation](#12-installation)
6-
- [1.3. Setup](#13-setup)
7-
- [1.3.1. Program.cs Example](#131-programcs-example)
8-
- [1.3.1.1. Using WebApplicationBuilder](#1311-using-webapplicationbuilder)
9-
- [1.3.1.2. Using IServiceCollection](#1312-using-iservicecollection)
10-
- [1.3.2. Appsettings.json Example](#132-appsettingsjson-example)
11-
- [1.4. Configuration Options Explained](#14-configuration-options-explained)
12-
- [1.5. Usage](#15-usage)
13-
- [1.5.1. Send SMS message](#151-send-sms-message)
14-
- [1.5.2. Send Email message](#152-send-email-message)
15-
- [1.6. Limitations](#16-limitations)
16-
- [1.7. License](#17-license)
17-
18-
## 1.1. Introduction
1+
# PandaTech.Communicator
2+
3+
## Introduction
194

205
**PandaTech.Communicator** is aimed to send Email and SMS messages to the clients of your service where you use this
216
library.
227

23-
- **Email:** By given setup it's easy and fast to configure and setup Email providers for later use by different
24-
channels.
25-
- **SMS:** By given setup it's easy and fast to configure and setup already integrated SMS providers for later use by
26-
different channels.
27-
- **Dexatel**
28-
- **Twilio**
8+
- **Email:** By given setup it's easy and fast to configure and setup Email providers for later use by different
9+
channels.
10+
- **SMS:** By given setup it's easy and fast to configure and setup already integrated SMS providers for later use by
11+
different channels.
12+
- **Dexatel**
13+
- **Twilio**
2914

3015
This package is ideal for efficient and reliable messaging in any application.
3116

32-
## 1.2. Installation
17+
## Installation
3318

3419
Install this NuGet library directly from the IDE package installer or by following command:
3520

3621
`dotnet add package PandaTech.Communicator`
3722

38-
## 1.3. Setup
23+
## Setup
3924

4025
To incorporate PandaTech.Communicator into your project, you have 2 primary methods to setup in your `Program.cs`:
4126

4227
The first method directly using `WebApplicationBuilder` from which `IConfiguration` is directly used. But for the second
4328
method builder is not accessible, so we pass `IConfiguration` into it as parameter.
4429

45-
- `builder.AddCommunicator();`
46-
- `services.AddCommunicator(configuration);`
30+
- `builder.AddCommunicator();`
31+
- `services.AddCommunicator(configuration);`
4732

4833
Configuration options can be specified either in `appsettings.json` or directly in `Program.cs`, with the latter taking
4934
precedence.
@@ -59,7 +44,7 @@ EmailChannels
5944
"MarketingSender",
6045
"SupportSender"
6146
};
62-
47+
6348
SmsChannels
6449
{
6550
"GeneralSender",
@@ -73,11 +58,11 @@ SmsChannels
7358
For each channel can be setup same provider, but it's recommended to have different sender, as they are dedicated for
7459
different purposes.
7560

76-
### 1.3.1. Program.cs Example
61+
### Program.cs Example
7762

7863
In case of using SSL by setting UseSsl = true use port number 456, otherwise use 587 for non SSL connection.
7964

80-
#### 1.3.1.1. Using `WebApplicationBuilder`
65+
#### Using `WebApplicationBuilder`
8166

8267
```csharp
8368
builder.AddCommunicator(options =>
@@ -143,7 +128,7 @@ builder.AddCommunicator(options =>
143128

144129
```
145130

146-
#### 1.3.1.2. Using `IServiceCollection`
131+
#### Using `IServiceCollection`
147132

148133
```csharp
149134
services.AddCommunicator(configuration, options =>
@@ -209,77 +194,77 @@ services.AddCommunicator(configuration, options =>
209194

210195
```
211196

212-
### 1.3.2. Appsettings.json Example
197+
### Appsettings.json Example
213198

214199
```json
215200
{
216-
"Logging": {
217-
"LogLevel": {
218-
"Default": "Information",
219-
"Microsoft.AspNetCore": "Warning"
220-
}
221-
},
222-
"Communicator": {
223-
"SmsFake": false,
224-
"SmsConfigurations": {
225-
"GeneralSender": {
226-
"Provider": "Dexatel",
227-
"From": "sender_name",
228-
"Properties": {
229-
"X-Dexatel-Key": "key"
230-
},
231-
"TimeoutMs": "10000"
232-
},
233-
"TransactionalSender": {
234-
"Provider": "Twilio",
235-
"From": "sender_number",
236-
"Properties": {
237-
"SID": "key",
238-
"AUTH_TOKEN": "token"
239-
},
240-
"TimeoutMs": "10000"
241-
}
201+
"Logging": {
202+
"LogLevel": {
203+
"Default": "Information",
204+
"Microsoft.AspNetCore": "Warning"
205+
}
242206
},
243-
"EmailFake": false,
244-
"EmailConfigurations": {
245-
"GeneralSender": {
246-
"SmtpServer": "smtp.gmail.com",
247-
"SmtpPort": 465, // 587
248-
"SmtpUsername": "vazgen",
249-
"SmtpPassword": "vazgen123",
250-
"SenderEmail": "[email protected]",
251-
"UseSsl": true, // false
252-
"TimeoutMs": "10000"
253-
},
254-
"TransactionalSender": {
255-
"SmtpServer": "smtp.gmail.com",
256-
"SmtpPort": 465, // 587
257-
"SmtpUsername": "vazgen",
258-
"SmtpPassword": "vazgen123",
259-
"SenderEmail": "[email protected]",
260-
"UseSsl": true, // false
261-
"TimeoutMs": "10000"
262-
}
207+
"Communicator": {
208+
"SmsFake": false,
209+
"SmsConfigurations": {
210+
"GeneralSender": {
211+
"Provider": "Dexatel",
212+
"From": "sender_name",
213+
"Properties": {
214+
"X-Dexatel-Key": "key"
215+
},
216+
"TimeoutMs": "10000"
217+
},
218+
"TransactionalSender": {
219+
"Provider": "Twilio",
220+
"From": "sender_number",
221+
"Properties": {
222+
"SID": "key",
223+
"AUTH_TOKEN": "token"
224+
},
225+
"TimeoutMs": "10000"
226+
}
227+
},
228+
"EmailFake": false,
229+
"EmailConfigurations": {
230+
"GeneralSender": {
231+
"SmtpServer": "smtp.gmail.com",
232+
"SmtpPort": 465, // 587
233+
"SmtpUsername": "vazgen",
234+
"SmtpPassword": "vazgen123",
235+
"SenderEmail": "[email protected]",
236+
"UseSsl": true, // false
237+
"TimeoutMs": "10000"
238+
},
239+
"TransactionalSender": {
240+
"SmtpServer": "smtp.gmail.com",
241+
"SmtpPort": 465, // 587
242+
"SmtpUsername": "vazgen",
243+
"SmtpPassword": "vazgen123",
244+
"SenderEmail": "[email protected]",
245+
"UseSsl": true, // false
246+
"TimeoutMs": "10000"
247+
}
248+
}
263249
}
264-
}
265250
}
266251
```
267252

268253
The configuration options in `appsettings.json` and `program.cs` (priority) are identical.
269254

270-
## 1.4. Configuration Options Explained
255+
## Configuration Options Explained
271256

272-
- **Communicator:** Global settings for PandaTech.Communicator
273-
- **SmsFake:** This setup is for fake SMS service to be used which doesn't send real SMS messages and just return
274-
`TTask.CompletedTask`.
275-
- **SmsConfigurations:** SMS configurations given by `appsettings.json` or via `builder.AddCommunicator()` options for
276-
SMS.
277-
- **EmailFake:** This setup is for fake Email service to be used which doesn't send real SMS messages and just return
278-
`TTask.CompletedTask`.
279-
- **EmailConfigurations:** Email configurations given by `appsettings.json` or via `builder.AddCommunicator()` options
280-
for Email.
257+
- **Communicator:** Global settings for PandaTech.Communicator
258+
- **SmsFake:** This setup is for fake SMS service to be used which doesn't send real SMS messages and just return
259+
`TTask.CompletedTask`.
260+
- **SmsConfigurations:** SMS configurations given by `appsettings.json` or via `builder.AddCommunicator()` options for
261+
SMS.
262+
- **EmailFake:** This setup is for fake Email service to be used which doesn't send real SMS messages and just return
263+
`TTask.CompletedTask`.
264+
- **EmailConfigurations:** Email configurations given by `appsettings.json` or via `builder.AddCommunicator()` options
265+
for Email.
281266

282-
## 1.5. Usage
267+
## Usage
283268

284269
In order to use the library, you need to generate `SmsMessage` or `EmailMessage` and use one of the interfaces mentioned
285270
above for the service you need to use.
@@ -314,8 +299,8 @@ Channel is set by `EmailChannels` or by `SmsChannels` classes with constant valu
314299
There are 2 interfaces `ISmsService` and `IEmailService` responsible for individual cases SMS or Email.
315300
Methods for sending SMS/Email messages are:
316301

317-
- **SendAsync:**
318-
- **SendBulkAsync:**
302+
- **SendAsync:**
303+
- **SendBulkAsync:**
319304

320305
The structure of the service interfaces are shown below.
321306

@@ -333,7 +318,7 @@ public interface IEmailService
333318
}
334319
```
335320

336-
## 1.5.1. Send SMS message
321+
## Send SMS message
337322

338323
```csharp
339324
var sms = new SmsMessage
@@ -363,7 +348,7 @@ public class GeneralSmsResponse
363348
}
364349
```
365350

366-
## 1.5.2. Send Email message
351+
## Send Email message
367352

368353
```csharp
369354
var email = new EmailMessage
@@ -386,10 +371,10 @@ email providers, so you can create your ouw return type and map returned string
386371
2.0.0 OK 8ONXSST18NU4.DSCFVS8PQ0Q13@test AM0PR08MB5346.eurprd08.prod.outlook.com
387372
```
388373

389-
## 1.6. Limitations
374+
## Limitations
390375

391376
PandaTech.Communicator works with all Email providers, but with only with existing integrations for SMS listed above.
392377

393-
## 1.7. License
378+
## License
394379

395-
PandaTech.Communicator is licensed under the MIT License.
380+
PandaTech.Communicator is licensed under the MIT License.

src/Communicator/Communicator.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>2.1.2</Version>
11+
<Version>2.1.3</Version>
1212
<PackageId>Pandatech.Communicator</PackageId>
1313
<Title>SMS and Email Communication helper</Title>
1414
<PackageTags>Pandatech, library, Sms, Email, Messages</PackageTags>
@@ -23,10 +23,10 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="MailKit" Version="4.10.0" />
27-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
28-
<PackageReference Include="MimeKit" Version="4.10.0" />
29-
<PackageReference Include="Pandatech.RegexBox" Version="3.0.1" />
26+
<PackageReference Include="MailKit" Version="4.12.1" />
27+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
28+
<PackageReference Include="MimeKit" Version="4.12.0" />
29+
<PackageReference Include="Pandatech.SharedKernel" Version="1.3.8" />
3030
</ItemGroup>
3131

3232
</Project>

src/Communicator/Helpers/EmailMessageValidator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Communicator.Models;
2-
using RegexBox;
2+
using SharedKernel.Helpers;
33

44
namespace Communicator.Helpers;
55

@@ -12,17 +12,17 @@ internal static void Validate(EmailMessage emailMessage)
1212
throw new ArgumentException("At least one recipient is required", nameof(emailMessage.Recipients));
1313
}
1414

15-
if (emailMessage.Recipients.Any(email => !PandaValidator.IsEmail(email)))
15+
if (emailMessage.Recipients.Any(email => !ValidationHelper.IsEmail(email)))
1616
{
1717
throw new ArgumentException("Invalid email address", nameof(emailMessage.Recipients));
1818
}
1919

20-
if (emailMessage.Cc.Count != 0 && emailMessage.Cc.Any(email => !PandaValidator.IsEmail(email)))
20+
if (emailMessage.Cc.Count != 0 && emailMessage.Cc.Any(email => !ValidationHelper.IsEmail(email)))
2121
{
2222
throw new ArgumentException("Invalid email address", nameof(emailMessage.Cc));
2323
}
2424

25-
if (emailMessage.Bcc.Count != 0 && emailMessage.Bcc.Any(email => !PandaValidator.IsEmail(email)))
25+
if (emailMessage.Bcc.Count != 0 && emailMessage.Bcc.Any(email => !ValidationHelper.IsEmail(email)))
2626
{
2727
throw new ArgumentException("Invalid email address", nameof(emailMessage.Bcc));
2828
}

src/Communicator/Helpers/SmsRecipients.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Communicator.Extensions;
2-
using RegexBox;
2+
using SharedKernel.Helpers;
33

44
namespace Communicator.Helpers;
55

@@ -9,7 +9,7 @@ internal static class SmsRecipients
99

1010
internal static string Transform(this string recipient)
1111
{
12-
if (PandaValidator.IsPandaFormattedPhoneNumber(recipient)
12+
if (ValidationHelper.IsPandaFormattedPhoneNumber(recipient)
1313
|| recipient.Any(c => CharsToCheck.Contains(c)))
1414
{
1515
recipient = recipient.RemovePhoneFormatParenthesesAndAdditionSign();
@@ -20,7 +20,7 @@ internal static string Transform(this string recipient)
2020

2121
internal static List<string> Transform(this List<string> recipients)
2222
{
23-
foreach (var recipient in recipients.Where(PandaValidator.IsPandaFormattedPhoneNumber))
23+
foreach (var recipient in recipients.Where(ValidationHelper.IsPandaFormattedPhoneNumber))
2424
{
2525
recipient.RemovePhoneFormatParenthesesAndAdditionSign();
2626
}

test/Communicator.Demo/Communicator.Demo.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
12-
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
11+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
12+
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.2" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

test/Communicator.Tests/Communicator.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
1414
<PackageReference Include="xunit" Version="2.9.3" />
15-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
15+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
<PrivateAssets>all</PrivateAssets>
1818
</PackageReference>

0 commit comments

Comments
 (0)