Skip to content

Commit

Permalink
qr code + store badges + signtaure + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
4kimov committed Mar 22, 2024
1 parent cb0a898 commit 74de968
Show file tree
Hide file tree
Showing 30 changed files with 689 additions and 238 deletions.
27 changes: 21 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
# CHANGELOG

**v0.1.5:**
## v0.2.0:

### New Features
- New social icons: `Service.Mastodon` and `Service.Rss`
- New `StoreBadges` component
- New `QrCode` component
- New `Signature` component
- New [examples](examples)

### Enhancements
- Only `src` is required for the `Image` component, all other params are optional
- Text for `ViewInBrowser` component is optional now
- Updated README & NUGET-README
- Dependency updates

## v0.1.5:
- `README.md`
- markdown supports ordered/unordered lists
- notice about test mode
- Support for test mode logging

**v0.1.4:**
## v0.1.4:
- `README.md` cleanup (listing of components)
- `Image` component now requires only `src`; the other params are optional
- `ViewInBrowser` component has changed: text is optional
- `coverlet.collector` upgrade

**v0.1.3:**
- Introduced new services as [social icons](examples/ConfirmEmailExample/Program.cs):
## v0.1.3:
- Introduced new services as [social icons](examples/VerificationExample/Program.cs):
- `Service.Phone` (converts into a link with `tel:` prefix)
- `Service.Facebook`
- `Service.YouTube`
Expand All @@ -26,11 +41,11 @@
- `Service.Threads`
- `Service.Telegram`

**v0.1.2:**
## v0.1.2:
- Introduced `CHANGELOG.md`
- Added `icon.png` to `PackageIcon`
- Minor example adjustments
- Minor `README.md` cleanup

**v0.1.1:**
## *v0.1.1:
- Initial implementation
89 changes: 4 additions & 85 deletions NUGET-README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Templateless .NET (C#)

[![Latest version](https://img.shields.io/nuget/v/Templateless)](https://www.nuget.org/packages/Templateless)
[![Github Actions](https://img.shields.io/github/actions/workflow/status/templateless/templateless-dotnet/tests.yml)](https://github.com/templateless/templateless-dotnet/actions)
[![Downloads](https://img.shields.io/nuget/dt/Templateless)](https://www.nuget.org/packages/Templateless)

## What is Templateless?

[Templateless](https://templateless.com) lets you generate and send transactional emails quickly and easily so you can ship faster 🚀
[Templateless](https://templateless.com) lets you generate and send transactional emails quickly and easily so you can focus on building your product.

It's perfect for SaaS, web apps, mobile apps, scripts and anywhere you have to send email programmatically.

## ✨ Features

Expand All @@ -20,86 +18,7 @@

## 🚀 Getting started

Install the [NuGet package](https://nuget.org/packages/Templateless):

```bash
Install-Package Templateless
```

Alternatively, using the .NET CLI:

```bash
dotnet add package Templateless
```

## 👩‍💻 Quick example

This is all it takes to send a signup confirmation email:

```cs
using System;
using System.Threading.Tasks;
using Templateless;

class Program
{
static async Task Main(string[] args)
{
try
{
var content = Content.Builder()
.Text("Hi, please **confirm your email**:")
.Button("Confirm Email", "https://your-company.com/signup/confirm?token=XYZ")
.Build();

var email = Email.Builder()
.To(new EmailAddress("<YOUR_CUSTOMERS_EMAIL_ADDRESS>"))
.Subject("Confirm your signup 👋")
.Content(content)
.Build();

var templateless = new TemplatelessClient("<YOUR_API_KEY>");
var emailIds = await templateless.SendEmailAsync(email);

Console.WriteLine(string.Join(", ", emailIds));
}
catch (TemplatelessException ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
catch (Exception ex)
{
Console.WriteLine($"An unexpected error occurred: {ex.Message}");
}
}
}
```

Note:

1. Get your **free API key** here: <https://app.templateless.com>
1. There are more C# examples in the [examples](examples) folder:

```bash
TEMPLATELESS_API_KEY=<YOUR_API_KEY> \
TEMPLATELESS_EMAIL_ADDRESS=<YOUR_EMAIL_ADDRESS> \
dotnet run --project ./examples/SimpleExample/SimpleExample.csproj
```

## 🤝 Contributing

- Contributions are more than welcome <3
- Please **star this repo** for more visibility ★

## 📫 Get in touch

- For customer support feel free to email us at [github@templateless.com](mailto:github@templateless.com)

- Have suggestions or want to give feedback? Here's how to reach us:
- For feature requests, please [start a discussion](https://github.com/templateless/templateless-dotnet/discussions)
- Found a bug? [Open an issue!](https://github.com/templateless/templateless-dotnet/issues)
- We are also on Twitter: [@Templateless](https://twitter.com/templateless)
### For full documentation, please visit the [GitHub repository](https://github.com/templateless/templateless-dotnet).

## 🍻 License

Expand Down
170 changes: 129 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ Text component allow you to insert a paragraph. Each paragraph supports basic ma

```cs
Content.Builder()
.Text("## Thank you for signing up")
.Text("Please **verify your email** by [clicking here](https://example.com/confirm?token=XYZ)")
.Build();
.Text("## Thank you for signing up")
.Text("Please **verify your email** by [clicking here](https://example.com/confirm?token=XYZ)")
.Build();
```

</details>
Expand All @@ -170,9 +170,8 @@ Link component adds an anchor tag. This is the same as a text component with the

```cs
Content.Builder()
.Link("Confirm Email", "https://example.com/confirm?token=XYZ") // or...
.Text("[Confirm Email](https://example.com/confirm?token=XYZ)")
.Build();
.Link("Confirm Email", "https://example.com/confirm?token=XYZ")
.Build();
```

</details>
Expand All @@ -182,8 +181,8 @@ Button can also be used as a call to action. Button color is set via your dashbo

```cs
Content.Builder()
.Button("Confirm Email", "https://example.com/confirm?token=XYZ")
.Build();
.Button("Confirm Email", "https://example.com/confirm?token=XYZ")
.Build();
```

</details>
Expand All @@ -193,14 +192,14 @@ Image component will link to an image within your email. Keep in mind that a lot

```cs
Content.Builder()
.Image(
"https://placekitten.com/300/200", // where the image is hosted
"https://example.com", // [optional] link url, if you want it to be clickable
300, // [optional] width
200, // [optional] height
"Alt text" // [optional] alternate text
)
.Build();
.Image(
"https://placekitten.com/300/200", // where the image is hosted
"https://example.com", // [optional] link url, if you want it to be clickable
300, // [optional] width
200, // [optional] height
"Alt text" // [optional] alternate text
)
.Build();
```

Only the `src` parameter is required; everything else is optional.
Expand Down Expand Up @@ -229,9 +228,9 @@ OTP component is designed for showing temporary passwords and reset codes.

```cs
Content.Builder()
.Text("Here's your **temporary login code**:")
.Otp("XY78-2BT0-YFNB-ALW9")
.Build();
.Text("Here's your **temporary login code**:")
.Otp("XY78-2BT0-YFNB-ALW9")
.Build();
```

</details>
Expand All @@ -243,26 +242,28 @@ These are all the supported platforms:

```cs
Content.Builder()
.Socials(new List<SocialItem>
{
new SocialItem(Service.Website, "https://example.com"),
new SocialItem(Service.Email, "username@example.com"),
new SocialItem(Service.Phone, "123-456-7890"), // `tel:` link
new SocialItem(Service.Facebook, "Username"),
new SocialItem(Service.YouTube, "ChannelID"),
new SocialItem(Service.Twitter, "Username"),
new SocialItem(Service.X, "Username"),
new SocialItem(Service.GitHub, "Username"),
new SocialItem(Service.Instagram, "Username"),
new SocialItem(Service.LinkedIn, "Username"),
new SocialItem(Service.Slack, "Org"),
new SocialItem(Service.Discord, "Username"),
new SocialItem(Service.TikTok, "Username"),
new SocialItem(Service.Snapchat, "Username"),
new SocialItem(Service.Threads, "Username"),
new SocialItem(Service.Telegram, "Username")
})
.Build();
.Socials(new List<SocialItem>
{
new SocialItem(Service.Website, "https://example.com"),
new SocialItem(Service.Email, "username@example.com"),
new SocialItem(Service.Phone, "123-456-7890"), // `tel:` link
new SocialItem(Service.Facebook, "Username"),
new SocialItem(Service.YouTube, "ChannelID"),
new SocialItem(Service.Twitter, "Username"),
new SocialItem(Service.X, "Username"),
new SocialItem(Service.GitHub, "Username"),
new SocialItem(Service.Instagram, "Username"),
new SocialItem(Service.LinkedIn, "Username"),
new SocialItem(Service.Slack, "Org"),
new SocialItem(Service.Discord, "Username"),
new SocialItem(Service.TikTok, "Username"),
new SocialItem(Service.Snapchat, "Username"),
new SocialItem(Service.Threads, "Username"),
new SocialItem(Service.Telegram, "Username"),
new SocialItem(Service.Mastodon, "@Username@example.com"),
new SocialItem(Service.Rss, "https://example.com/blog")
})
.Build();
```

</details>
Expand All @@ -276,10 +277,97 @@ You can optionally provide the text for the link. If none is provided, default i

```cs
Content.Builder()
.ViewInBrowser("Read Email in Browser")
.Build();
.ViewInBrowser("Read Email in Browser")
.Build();
```

</details>
<details><summary>Store Badges</summary>

Link to your mobile apps via store badges:

```cs
Content.Builder()
.StoreBadges(new List<StoreBadgeItem>
{
new StoreBadgeItem(StoreBadge.AppStore, "https://apps.apple.com/us/app/example/id1234567890"),
new StoreBadgeItem(StoreBadge.GooglePlay, "https://play.google.com/store/apps/details?id=com.example"),
new StoreBadgeItem(StoreBadge.MicrosoftStore, "https://apps.microsoft.com/detail/example"),
})
.Build();
```

</details>
<details><summary>QR Code</summary>

You can also generate QR codes on the fly. They will be shown as images inside the email.

Here are all the supported data types:

```cs
// URL
Content.Builder()
.QrCode("https://example.com")
.Build();

// Email
Content.Builder()
.Component(QrCode.Email("user@example.com"))
.Build();

// Phone
Content.Builder()
.Component(QrCode.Phone("123-456-7890"))
.Build();

// SMS / Text message
Content.Builder()
.Component(QrCode.Sms("123-456-7890"))
.Build();

// Geo coordinates
Content.Builder()
.Component(QrCode.Coordinates(37.773972, -122.431297))
.Build();

// Crypto address (for now only Bitcoin and Ethereum are supported)
Content.Builder()
.Component(QrCode.CryptocurrencyAddress(Cryptocurrency.Bitcoin, "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"))
.Build();

// You can also encode any binary data
Content.Builder()
.Component(new QrCode(new byte[] { 1, 2, 3 }))
.Build();
```

</details>
<details><summary>Signature</summary>

Generated signatures can be added to your emails to give a bit of a personal touch. This will embed an image with your custom text using one of several available fonts:

```cs
// Signature with a default font
Content.Builder()
.Signature("John Smith")
.Build();

// Signature with a custom font
Content.Builder()
.Signature("John Smith", SignatureFont.ReenieBeanie)
.Build();
```

These are the available fonts:

- `SignatureFont.ReenieBeanie` [preview →](https://fonts.google.com/specimen/Reenie+Beanie)
- `SignatureFont.MeowScript` [preview →](https://fonts.google.com/specimen/Meow+Script)
- `SignatureFont.Caveat` [preview →](https://fonts.google.com/specimen/Caveat)
- `SignatureFont.Zeyada` [preview →](https://fonts.google.com/specimen/Zeyada)
- `SignatureFont.Petemoss` [preview →](https://fonts.google.com/specimen/Petemoss)

Signature should not exceed 64 characters. Only alphanumeric characters and most common symbols are allowed.

</details>

---
Expand Down
Loading

0 comments on commit 74de968

Please sign in to comment.