Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Elsa.Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "devops", "devops", "{9B6DFC
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.DevOps.GitHub", "src\devops\Elsa.DevOps.GitHub\Elsa.DevOps.GitHub.csproj", "{4E8D5DEA-6FB5-8878-0029-584C8F0D2D68}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integrations", "integrations", "{1DAA7FA3-95BE-49F8-B989-0457DBD6CF3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Integrations.Mailchimp", "src\integrations\Elsa.Integrations.Mailchimp\Elsa.Integrations.Mailchimp.csproj", "{FE2BCFD7-D6B6-4429-B964-2209F56AD06C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Integrations.Mailchimp.Tests", "test\unit\Elsa.Integrations.Mailchimp.Tests\Elsa.Integrations.Mailchimp.Tests.csproj", "{C57C6B43-DAE4-4C38-AD27-FC021AA2F4A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -603,6 +609,14 @@ Global
{4E8D5DEA-6FB5-8878-0029-584C8F0D2D68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E8D5DEA-6FB5-8878-0029-584C8F0D2D68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E8D5DEA-6FB5-8878-0029-584C8F0D2D68}.Release|Any CPU.Build.0 = Release|Any CPU
{FE2BCFD7-D6B6-4429-B964-2209F56AD06C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE2BCFD7-D6B6-4429-B964-2209F56AD06C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE2BCFD7-D6B6-4429-B964-2209F56AD06C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE2BCFD7-D6B6-4429-B964-2209F56AD06C}.Release|Any CPU.Build.0 = Release|Any CPU
{C57C6B43-DAE4-4C38-AD27-FC021AA2F4A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C57C6B43-DAE4-4C38-AD27-FC021AA2F4A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C57C6B43-DAE4-4C38-AD27-FC021AA2F4A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C57C6B43-DAE4-4C38-AD27-FC021AA2F4A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -717,6 +731,9 @@ Global
{59C29BC8-ED95-8F0B-323E-A988EADF3D38} = {AF041BAE-B45A-428B-B7F5-921CCB895558}
{9B6DFC6C-2514-4784-9952-9B0B913434F9} = {527248D6-B851-4C8D-8667-E2FB0A91DABF}
{4E8D5DEA-6FB5-8878-0029-584C8F0D2D68} = {9B6DFC6C-2514-4784-9952-9B0B913434F9}
{1DAA7FA3-95BE-49F8-B989-0457DBD6CF3F} = {527248D6-B851-4C8D-8667-E2FB0A91DABF}
{FE2BCFD7-D6B6-4429-B964-2209F56AD06C} = {1DAA7FA3-95BE-49F8-B989-0457DBD6CF3F}
{C57C6B43-DAE4-4C38-AD27-FC021AA2F4A6} = {AF041BAE-B45A-428B-B7F5-921CCB895558}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {11A771DA-B728-445E-8A88-AE1C84C3B3A6}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using Elsa.Integrations.Mailchimp.Activities;
using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.Models;
using JetBrains.Annotations;
using MailChimp.Net.Models;

namespace Elsa.Integrations.Mailchimp.Activities.Campaigns;

/// <summary>
/// Creates a new campaign in Mailchimp.
/// </summary>
[Activity(
"Elsa.Mailchimp.Campaigns",
"Mailchimp Campaigns",
"Creates a new campaign in Mailchimp.",
DisplayName = "Create Campaign")]
[UsedImplicitly]
public class CreateCampaign : MailchimpActivity
{
/// <summary>
/// The type of campaign (regular, plaintext, absplit, rss, variate).
/// </summary>
[Input(Description = "The type of campaign (regular, plaintext, absplit, rss, variate).")]
public Input<string> Type { get; set; } = new("regular");

/// <summary>
/// The list ID to send the campaign to.
/// </summary>
[Input(Description = "The list ID to send the campaign to.")]
public Input<string> ListId { get; set; } = null!;

/// <summary>
/// The subject line for the campaign.
/// </summary>
[Input(Description = "The subject line for the campaign.")]
public Input<string> SubjectLine { get; set; } = null!;

/// <summary>
/// The title of the campaign.
/// </summary>
[Input(Description = "The title of the campaign.")]
public Input<string?> Title { get; set; } = default!;

/// <summary>
/// The from name for the campaign.
/// </summary>
[Input(Description = "The from name for the campaign.")]
public Input<string?> FromName { get; set; } = default!;

/// <summary>
/// The reply-to email address for the campaign.
/// </summary>
[Input(Description = "The reply-to email address for the campaign.")]
public Input<string?> ReplyTo { get; set; } = default!;

/// <summary>
/// The preview text for the campaign.
/// </summary>
[Input(Description = "The preview text for the campaign.")]
public Input<string?> PreviewText { get; set; } = default!;

/// <summary>
/// The created campaign.
/// </summary>
[Output(Description = "The created campaign.")]
public Output<Campaign> CreatedCampaign { get; set; } = default!;

/// <summary>
/// Executes the activity.
/// </summary>
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var type = context.Get(Type) ?? "regular";
var listId = context.Get(ListId)!;
var subjectLine = context.Get(SubjectLine)!;
var title = context.Get(Title);
var fromName = context.Get(FromName);
var replyTo = context.Get(ReplyTo);
var previewText = context.Get(PreviewText);

var client = GetClient(context);

var campaign = new Campaign
{
Type = Enum.Parse<CampaignType>(type, true),
Recipients = new Recipient
{
ListId = listId
},
Settings = new Setting
{
SubjectLine = subjectLine,
Title = title,
FromName = fromName,
ReplyTo = replyTo,
PreviewText = previewText
}
};

var result = await client.Campaigns.AddAsync(campaign);
context.Set(CreatedCampaign, result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Elsa.Integrations.Mailchimp.Activities;
using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.Models;
using JetBrains.Annotations;

namespace Elsa.Integrations.Mailchimp.Activities.Campaigns;

/// <summary>
/// Deletes a campaign in Mailchimp.
/// </summary>
[Activity(
"Elsa.Mailchimp.Campaigns",
"Mailchimp Campaigns",
"Deletes a campaign in Mailchimp.",
DisplayName = "Delete Campaign")]
[UsedImplicitly]
public class DeleteCampaign : MailchimpActivity
{
/// <summary>
/// The ID of the campaign to delete.
/// </summary>
[Input(Description = "The ID of the campaign to delete.")]
public Input<string> CampaignId { get; set; } = null!;

/// <summary>
/// Indicates whether the operation was successful.
/// </summary>
[Output(Description = "Indicates whether the operation was successful.")]
public Output<bool> Success { get; set; } = default!;

/// <summary>
/// Executes the activity.
/// </summary>
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var campaignId = context.Get(CampaignId)!;
var client = GetClient(context);

try
{
await client.Campaigns.DeleteAsync(campaignId);
context.Set(Success, true);
}
catch
{
context.Set(Success, false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Elsa.Integrations.Mailchimp.Activities;
using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.Models;
using JetBrains.Annotations;
using MailChimp.Net.Models;

namespace Elsa.Integrations.Mailchimp.Activities.Campaigns;

/// <summary>
/// Retrieves metadata of a specified campaign from Mailchimp.
/// </summary>
[Activity(
"Elsa.Mailchimp.Campaigns",
"Mailchimp Campaigns",
"Retrieves metadata of a specified campaign from Mailchimp.",
DisplayName = "Get Campaign")]
[UsedImplicitly]
public class GetCampaign : MailchimpActivity
{
/// <summary>
/// The ID of the campaign to retrieve.
/// </summary>
[Input(Description = "The ID of the campaign to retrieve.")]
public Input<string> CampaignId { get; set; } = null!;

/// <summary>
/// The retrieved campaign.
/// </summary>
[Output(Description = "The retrieved campaign.")]
public Output<Campaign> RetrievedCampaign { get; set; } = default!;

/// <summary>
/// Executes the activity.
/// </summary>
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var campaignId = context.Get(CampaignId)!;
var client = GetClient(context);

var campaign = await client.Campaigns.GetAsync(campaignId);
context.Set(RetrievedCampaign, campaign);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using Elsa.Integrations.Mailchimp.Activities;
using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.Models;
using JetBrains.Annotations;
using MailChimp.Net.Models;

namespace Elsa.Integrations.Mailchimp.Activities.Campaigns;

/// <summary>
/// Updates an existing campaign in Mailchimp.
/// </summary>
[Activity(
"Elsa.Mailchimp.Campaigns",
"Mailchimp Campaigns",
"Updates an existing campaign in Mailchimp.",
DisplayName = "Update Campaign")]
[UsedImplicitly]
public class UpdateCampaign : MailchimpActivity
{
/// <summary>
/// The ID of the campaign to update.
/// </summary>
[Input(Description = "The ID of the campaign to update.")]
public Input<string> CampaignId { get; set; } = null!;

/// <summary>
/// The subject line for the campaign.
/// </summary>
[Input(Description = "The subject line for the campaign.")]
public Input<string?> SubjectLine { get; set; } = default!;

/// <summary>
/// The title of the campaign.
/// </summary>
[Input(Description = "The title of the campaign.")]
public Input<string?> Title { get; set; } = default!;

/// <summary>
/// The from name for the campaign.
/// </summary>
[Input(Description = "The from name for the campaign.")]
public Input<string?> FromName { get; set; } = default!;

/// <summary>
/// The reply-to email address for the campaign.
/// </summary>
[Input(Description = "The reply-to email address for the campaign.")]
public Input<string?> ReplyTo { get; set; } = default!;

/// <summary>
/// The preview text for the campaign.
/// </summary>
[Input(Description = "The preview text for the campaign.")]
public Input<string?> PreviewText { get; set; } = default!;

/// <summary>
/// The updated campaign.
/// </summary>
[Output(Description = "The updated campaign.")]
public Output<Campaign> UpdatedCampaign { get; set; } = default!;

/// <summary>
/// Executes the activity.
/// </summary>
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var campaignId = context.Get(CampaignId)!;
var subjectLine = context.Get(SubjectLine);
var title = context.Get(Title);
var fromName = context.Get(FromName);
var replyTo = context.Get(ReplyTo);
var previewText = context.Get(PreviewText);

var client = GetClient(context);

var campaign = new Campaign
{
Id = campaignId,
Settings = new Setting()
};

if (!string.IsNullOrEmpty(subjectLine))
campaign.Settings.SubjectLine = subjectLine;
if (!string.IsNullOrEmpty(title))
campaign.Settings.Title = title;
if (!string.IsNullOrEmpty(fromName))
campaign.Settings.FromName = fromName;
if (!string.IsNullOrEmpty(replyTo))
campaign.Settings.ReplyTo = replyTo;
if (!string.IsNullOrEmpty(previewText))
campaign.Settings.PreviewText = previewText;

var result = await client.Campaigns.UpdateAsync(campaignId, campaign);
context.Set(UpdatedCampaign, result);
}
}
Loading