Skip to content

Commit

Permalink
Shorter method names in (I)EmailComposer (#19)
Browse files Browse the repository at this point in the history
* Remove Set prefix from IEmailComposer methods
* Update readme
* Bump example packages
  • Loading branch information
hbulens committed Jul 8, 2024
1 parent a7dc0b5 commit 485089f
Show file tree
Hide file tree
Showing 28 changed files with 185 additions and 854 deletions.
Binary file removed assets/letter.png
Binary file not shown.
712 changes: 0 additions & 712 deletions assets/letter.svg

This file was deleted.

10 changes: 5 additions & 5 deletions examples/gmail/Facteur.Examples.Gmail.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Facteur" Version="2.0.0-beta.2" />
<PackageReference Include="Facteur.Compilers.Scriban" Version="2.0.0-beta.2" />
<PackageReference Include="Facteur.Resolvers.ViewModel" Version="2.0.0-beta.2" />
<PackageReference Include="Facteur.Smtp" Version="2.0.0-beta.2" />
<PackageReference Include="Facteur.TemplateProviders.IO" Version="2.0.0-beta.2" />
<PackageReference Include="Facteur" Version="2.0.0" />
<PackageReference Include="Facteur.Compilers.Scriban" Version="2.0.0" />
<PackageReference Include="Facteur.Resolvers.ViewModel" Version="2.0.0" />
<PackageReference Include="Facteur.Smtp" Version="2.0.0" />
<PackageReference Include="Facteur.TemplateProviders.IO" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Facteur.Attachments.IO/Facteur.Attachments.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>Add attachments using simple IO</Description>
<PackageTags>Facteur;Email;Mail;RazorEngine;Scriban;SendGrid;Graph;SMTP</PackageTags>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
Expand Down
15 changes: 7 additions & 8 deletions src/Facteur.Attachments.IO/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@ public async Task SendConfirmationMail(string customerMail, string customerName)
new AppDirectoryTemplateProvider("Templates", ".sbnhtml"),
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetModel(new TestMailModel { Email = customerMail, Name = customerMail })
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Build();
EmailRequest request = await composer
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.Build(new TestMailModel { Email = customerMail, Name = customerMail });

EmailRequest populatedRequest = await builder.BuildAsync(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Description>Create email bodies using the Scriban template engine.</Description>
<PackageTags>Facteur;Email;Mail;Scriban</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/dimesoftware/facteur/master/assets/facteur.png?raw=true</PackageIconUrl>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
Expand Down
20 changes: 10 additions & 10 deletions src/Facteur.Compilers.Scriban/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public async Task SendConfirmationMail(string customerMail, string customerName)
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail });

SmtpCredentials credentials = new("smtp.gmail.com", "587", "false", "true", "[email protected]", "mypassword");
Expand All @@ -98,11 +98,11 @@ If you use DI, you can just use `IMailer` and use the overload that exposes the
public async Task SendConfirmationMail(string customerMail, string customerName)
{
await mailer.SendMailAsync(x => x
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail }));
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public async Task ServiceCollection_Defaults_ShouldConstructAndSendMail()
ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
IMailer mailer = serviceProvider.GetService<IMailer>();
//await mailer.SendMailAsync(x => x
//.SetSubject("Hello world")
//.SetFrom("[email protected]")
//.SetTo("[email protected]")
//.Subject("Hello world")
//.From("[email protected]")
//.To("[email protected]")
//.BuildAsync(new TestMailModel { Email = "[email protected]", Name = "Guy Gadbois" }));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Facteur;Email;Mail;RazorEngine;Scriban;SendGrid;Graph;SMTP</PackageTags>
<Description>ASP.NET Core extensions for facteur.</Description>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
Expand Down
20 changes: 10 additions & 10 deletions src/Facteur.Extensions.DependencyInjection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public async Task SendConfirmationMail(string customerMail, string customerName)
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail });

SmtpCredentials credentials = new("smtp.gmail.com", "587", "false", "true", "[email protected]", "mypassword");
Expand All @@ -99,11 +99,11 @@ If you use DI, you can just use `IMailer` and use the overload that exposes the
public async Task SendConfirmationMail(string customerMail, string customerName)
{
await mailer.SendMailAsync(x => x
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail }));
}
```
Expand Down
6 changes: 3 additions & 3 deletions src/Facteur.MsGraph.Tests/MsGraphTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public async Task Graph_SendMail_ShouldSend()

EmailComposer composer = new();
EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.BuildAsync(new TestMailModel { Email = "[email protected]", Name = "Guy Gadbois" });

Mock<IMailer> mock = new();
Expand Down
2 changes: 1 addition & 1 deletion src/Facteur.MsGraph/Facteur.MsGraph.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Facteur;Email;Mail;Graph;Microsoft</PackageTags>
<Description>Send emails using the MS Graph endpoint</Description>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
Expand Down
20 changes: 10 additions & 10 deletions src/Facteur.MsGraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public async Task SendConfirmationMail(string customerMail, string customerName)
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail });

SmtpCredentials credentials = new("smtp.gmail.com", "587", "false", "true", "[email protected]", "mypassword");
Expand All @@ -98,11 +98,11 @@ If you use DI, you can just use `IMailer` and use the overload that exposes the
public async Task SendConfirmationMail(string customerMail, string customerName)
{
await mailer.SendMailAsync(x => x
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail }));
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageTags>Facteur;Email;Mail</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>Map and resolve email templates using the view model type names</Description>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
20 changes: 10 additions & 10 deletions src/Facteur.Resolvers.ViewModel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public async Task SendConfirmationMail(string customerMail, string customerName)
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail });

SmtpCredentials credentials = new("smtp.gmail.com", "587", "false", "true", "[email protected]", "mypassword");
Expand All @@ -98,11 +98,11 @@ If you use DI, you can just use `IMailer` and use the overload that exposes the
public async Task SendConfirmationMail(string customerMail, string customerName)
{
await mailer.SendMailAsync(x => x
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail }));
}
```
Expand Down
18 changes: 9 additions & 9 deletions src/Facteur.SendGrid.Tests/SendGridTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public void Sendgrid_SendMail_KeyIsNull_ShouldThrowException()
{
EmailComposer composer = new();
EmailRequest request = composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Build();

Assert.ThrowsException<ArgumentNullException>(() => new SendGridMailer(null));
Expand All @@ -27,9 +27,9 @@ public void Sendgrid_SendMail_KeyIsEmpty_ShouldThrowException()
{
EmailComposer composer = new();
EmailRequest request = composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Build();

Assert.ThrowsException<ArgumentNullException>(() => new SendGridMailer(""));
Expand All @@ -40,9 +40,9 @@ public void Sendgrid_SendMail_KeyIsNotEmpty_ShouldConstruct()
{
EmailComposer composer = new();
EmailRequest request = composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Build();

IMailer mailer = new SendGridMailer("MySGKey");
Expand Down
2 changes: 1 addition & 1 deletion src/Facteur.SendGrid/Facteur.SendGrid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Facteur;Email;Mail;SendGrid</PackageTags>
<Description>Send emails using the SendGrid endpoint</Description>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
Expand Down
20 changes: 10 additions & 10 deletions src/Facteur.SendGrid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public async Task SendConfirmationMail(string customerMail, string customerName)
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail });

SmtpCredentials credentials = new("smtp.gmail.com", "587", "false", "true", "[email protected]", "mypassword");
Expand All @@ -99,11 +99,11 @@ If you use DI, you can just use `IMailer` and use the overload that exposes the
public async Task SendConfirmationMail(string customerMail, string customerName)
{
await mailer.SendMailAsync(x => x
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = customerMail, Name = customerMail }));
}
```
Expand Down
30 changes: 15 additions & 15 deletions src/Facteur.Smtp.Tests/SmtpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public async Task Smtp_SendTemplateMail_ShouldSend()
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]", "Facteur")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]", "Facteur")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = "[email protected]", Name = "Guy Gadbois" });

IMailer mailer = new SmtpMailer(credentials);
Expand All @@ -46,11 +46,11 @@ public async Task Smtp_SendTemplateMail_SimulateDependencyInjection_ShouldSend()
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.BuildAsync(new TestMailModel { Email = "[email protected]", Name = "Guy Gadbois" });

IMailer mailer = new SmtpMailer(credentials);
Expand Down Expand Up @@ -84,11 +84,11 @@ public async Task Smtp_SendTemplateMail_WithAttachments_ShouldSend()
new ViewModelTemplateResolver());

EmailRequest request = await composer
.SetSubject("Hello world")
.SetFrom("[email protected]")
.SetTo("[email protected]")
.SetCc("[email protected]")
.SetBcc("[email protected]")
.Subject("Hello world")
.From("[email protected]")
.To("[email protected]")
.Cc("[email protected]")
.Bcc("[email protected]")
.Attach(attachments)
.BuildAsync(new TestMailModel { Email = "[email protected]", Name = "Guy Gadbois" });

Expand Down
2 changes: 1 addition & 1 deletion src/Facteur.Smtp/Facteur.Smtp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Facteur;Email;Mail;SMTP</PackageTags>
<Description>Send emails using SMTP</Description>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
Expand Down
Loading

0 comments on commit 485089f

Please sign in to comment.