Skip to content

Commit ba90593

Browse files
Gh 141 update email builder starter kit and related code (#142)
* GH-141 :: update version of Email Builder Starter Kit * GH-141 :: Rename mapper folder, add IEmailDataMapper implementation * GH-141 :: replace obsolete EmailContext functionality with EmailData * GH-141 :: Adjust exception catching chain * GH-141 :: refactor to check content type name instead of using try/catch fallbacks
1 parent 1996c29 commit ba90593

17 files changed

+256
-165
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Kentico.Xperience.Mjml.StarterKit.Rcl.Contracts;
2+
3+
/// <summary>
4+
/// Default implementation of the email data contract.
5+
/// </summary>
6+
public class EmailData : IEmailData
7+
{
8+
/// <summary>
9+
/// Initializes a new instance of the <see cref="EmailData"/> class.
10+
/// </summary>
11+
/// <param name="emailSubject">The email subject line.</param>
12+
/// <param name="emailPreviewText">The email preview text.</param>
13+
public EmailData(string? emailSubject, string? emailPreviewText = null)
14+
{
15+
EmailSubject = emailSubject ?? string.Empty;
16+
EmailPreviewText = emailPreviewText;
17+
}
18+
19+
/// <inheritdoc />
20+
public string? EmailSubject { get; }
21+
22+
/// <inheritdoc />
23+
public string? EmailPreviewText { get; }
24+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Kentico.Xperience.Mjml.StarterKit.Rcl.Contracts;
2+
3+
/// <summary>
4+
/// Contract defining the essential email data properties required by the Email Builder Starter Kit template.
5+
/// This contract is populated by implementations of <see cref="Mapping.IEmailDataMapper"/>.
6+
/// </summary>
7+
public interface IEmailData
8+
{
9+
/// <summary>
10+
/// Gets the email subject line.
11+
/// </summary>
12+
string? EmailSubject { get; }
13+
14+
/// <summary>
15+
/// Gets the email preview text displayed in email clients.
16+
/// </summary>
17+
string? EmailPreviewText { get; }
18+
}

src/Kentico.Xperience.Mjml.StarterKit.Rcl/Kentico.Xperience.Mjml.StarterKit.Rcl.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<Nullable>enable</Nullable>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<RootNamespace>Kentico.Xperience.Mjml.StarterKit.Rcl</RootNamespace>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<RootNamespace>Kentico.Xperience.Mjml.StarterKit.Rcl</RootNamespace>
88
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
9-
<IsPackable>true</IsPackable>
10-
<EnableScopedCss>false</EnableScopedCss>
9+
<IsPackable>true</IsPackable>
10+
<EnableScopedCss>false</EnableScopedCss>
1111
</PropertyGroup>
1212

1313
<ItemGroup>
@@ -28,7 +28,7 @@
2828
<ItemGroup>
2929
<PackageReference Include="Kentico.Xperience.WebApp" />
3030
<PackageReference Include="Microsoft.AspNetCore.Components.Web" />
31-
<PackageReference Include="Kentico.Xperience.Mjml" />
31+
<PackageReference Include="Kentico.Xperience.Mjml" />
3232
</ItemGroup>
3333

3434
<ItemGroup>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
namespace Kentico.Xperience.Mjml.StarterKit.Rcl.Mapping;
22

33
/// <summary>
4-
/// Defines a mapper for converting web page components into email builder widget models.
4+
/// Defines a mapper for converting content items into email builder widget models.
55
/// </summary>
66
public interface IComponentModelMapper<TWidgetModel>
77
{
88
/// <summary>
9-
/// Maps a web page component to a widget model based on its GUID.
9+
/// Maps a content item to a widget model based on its GUID.
1010
/// </summary>
11-
/// <param name="webPageItemGuid">The GUID of the web page component to map.</param>
11+
/// <param name="itemGuid">The GUID of the content item to map.</param>
1212
/// <param name="languageName">The language name for the email channel.</param>
1313
/// <returns>A widget model of type <typeparamref name="TWidgetModel"/>.</returns>
14-
public Task<TWidgetModel> Map(Guid webPageItemGuid, string languageName);
14+
public Task<TWidgetModel> Map(Guid itemGuid, string languageName);
1515
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Kentico.EmailBuilder.Web.Mvc;
2+
using Kentico.Xperience.Mjml.StarterKit.Rcl.Contracts;
3+
4+
namespace Kentico.Xperience.Mjml.StarterKit.Rcl.Mapping;
5+
6+
/// <summary>
7+
/// Defines a mapper for converting strongly-typed email content into the email data contract.
8+
/// Implementations should use <see cref="EmailContext.GetEmail{T}(CancellationToken)"/> to retrieve strongly-typed
9+
/// email data and map it to the <see cref="IEmailData"/> contract.
10+
/// </summary>
11+
public interface IEmailDataMapper
12+
{
13+
/// <summary>
14+
/// Maps strongly-typed email content to the email data contract.
15+
/// </summary>
16+
/// <returns>An instance of <see cref="IEmailData"/> containing the mapped email data.</returns>
17+
Task<IEmailData> Map();
18+
}

0 commit comments

Comments
 (0)