diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cd6608..116894b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # CHANGELOG -**Unreleased:** -- `README.md`: markdown supports ordered/unordered lists +**v0.1.5:** +- `README.md` + - markdown supports ordered/unordered lists + - notice about test mode +- Support for test mode logging **v0.1.4:** - `README.md` cleanup (listing of components) diff --git a/README.md b/README.md index 1f1e65f..61af4e9 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,18 @@ There are more C# examples in the [examples](examples) folder ✨ > [!NOTE] > 🚧 **The SDK is not stable yet.** This API might change as more features are added. Please watch the repo for the changes in the [CHANGELOG](CHANGELOG.md). +## 🏗 Debugging + +You can generate _test API keys_ by activating the **Test Mode** in your dashboard. By using these keys, you'll be able to view your fully rendered emails without actually sending them. + +When you use a test API key in your SDK, the following output will appear in your logs when you try to send an email: + +```log +Templateless [TEST MODE]: Emailed user@example.com, preview: https://tmpl.sh/ATMxHLX4r9aE +``` + +The preview link will display the email, but you must be logged in to Templateless to view it. + ## 🔳 Components Emails are crafted programmatically by making function calls. There's no dealing with HTML or drag-and-drop builders. @@ -260,7 +272,7 @@ If you'd like your recipients to be able to read the email in a browser, you can You can optionally provide the text for the link. If none is provided, default is used: "View in browser" -**This will make the email public to anyone that has access to the link.** +**Anyone who knows the link will be able to see the email.** ```cs Content.Builder() diff --git a/src/Templateless/Templateless.csproj b/src/Templateless/Templateless.csproj index 1d4ad33..41d81eb 100644 --- a/src/Templateless/Templateless.csproj +++ b/src/Templateless/Templateless.csproj @@ -8,7 +8,7 @@ Library Templateless - 0.1.4 + 0.1.5 Ship faster by sending elegant emails using just code Templateless;email;templates https://raw.githubusercontent.com/templateless/templateless-dotnet/main/icon.png diff --git a/src/Templateless/TemplatelessClient.cs b/src/Templateless/TemplatelessClient.cs index c6b6e51..d5fdd6e 100644 --- a/src/Templateless/TemplatelessClient.cs +++ b/src/Templateless/TemplatelessClient.cs @@ -55,8 +55,17 @@ public async Task> SendEmailsAsync(List emails) } var responseContent = await response.Content.ReadAsStringAsync(); - var sentEmailIds = JsonConvert.DeserializeObject(responseContent)?.Emails; - return sentEmailIds ?? new List(); + var res = JsonConvert.DeserializeObject(responseContent); + + if (res.Previews != null) + { + foreach (var preview in res.Previews) + { + Console.WriteLine($"Templateless [TEST MODE]: Emailed {preview.Email}, preview: https://tmpl.sh/{preview.Preview}"); + } + } + + return res?.Emails ?? new List(); } private ErrorType ParseErrorType(HttpStatusCode statusCode) @@ -73,9 +82,19 @@ private ErrorType ParseErrorType(HttpStatusCode statusCode) } } + public class EmailResponsePreview + { + [JsonProperty("preview")] + public string Preview { get; set; } + [JsonProperty("email")] + public string Email { get; set; } + } + public class EmailResponse { [JsonProperty("emails")] public List? Emails { get; set; } + [JsonProperty("previews")] + public List? Previews { get; set; } } }