-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50e983c
commit a6a9962
Showing
6 changed files
with
41 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"items": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
using System.Collections.Immutable; | ||
using System.Net; | ||
using System.Net.Http.Headers; | ||
using System.Text.Json; | ||
using System.Text; | ||
using System.Text.Json; | ||
|
||
namespace Unator; | ||
|
||
public static class EmailExample | ||
{ | ||
public static async Task Run() | ||
{ | ||
var email = new EmailSwitch( | ||
new EmailService(new Resend("resend-api-token"), new DayLimiter(100)), | ||
new EmailService(new Brevo("brevo-api-token"), new DayLimiter(300)), | ||
new EmailService(new SendGrid("send-grid-api-token"), new DayLimiter(100)) | ||
); | ||
|
||
var sent = await email.Send("[email protected]", "Roman Koshchei", | ||
to: ["[email protected]"], | ||
subject: "I own Flurium", | ||
text: "Hi me from flurium account!", | ||
html: "<h1>Hi me from flurium account!</h1>" | ||
); | ||
|
||
Console.WriteLine(sent switch | ||
{ | ||
EmailStatus.Success => "Success", | ||
EmailStatus.LimitReached => "Limits are reached", | ||
_ => "Can't send an email" | ||
}); | ||
} | ||
} | ||
|
||
public interface ILimiter | ||
{ | ||
/// <summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace Unator; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,5 @@ | ||
using System.Net; | ||
using Unator; | ||
using static Unator.EnvInteresting; | ||
using Unator; | ||
|
||
//EnvExample.Run(); | ||
|
||
var email = new EmailSwitch( | ||
new EmailService(new Resend("resend-api-token"), new DayLimiter(100)), | ||
new EmailService(new Brevo("brevo-api-token"), new DayLimiter(300)), | ||
new EmailService(new SendGrid("send-grid-api-token"), new DayLimiter(100)) | ||
); | ||
|
||
// In future I plan create an email builder | ||
// So it will be easy to create text and html versions at the same time | ||
// For example Header("Hi me from flurium account!") | ||
|
||
var sent = await email.Send("[email protected]", "Roman Koshchei", | ||
to: ["[email protected]"], | ||
subject: "I own Flurium", | ||
text: "Hi me from flurium account!", | ||
html: "<h1>Hi me from flurium account!</h1>" | ||
); | ||
|
||
Console.WriteLine(sent switch | ||
{ | ||
EmailStatus.Success => "Success", | ||
EmailStatus.LimitReached => "Limits are reached", | ||
_ => "Can't send an email" | ||
}); | ||
await EmailExample.Run(); |