Skip to content

Commit 08b6bd3

Browse files
authored
Merge pull request #106 from umbraco/v14/feature/43244-V14-Integrations-(ActiveCampaign/Forms)
V14 integrations (active campaign/forms)
2 parents 74ccf42 + d14ee6f commit 08b6bd3

File tree

115 files changed

+16696
-875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+16696
-875
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ src/Umbraco.Forms.Integrations.Testsite.V14/umbraco
1616
src/Umbraco.Forms.Integrations.Testsite.V14/Views
1717
src/Umbraco.Forms.Integrations.Testsite.V14/wwwroot
1818
src/Umbraco.Forms.Integrations.Automation.Zapier/wwwroot
19+
src/Umbraco.Forms.Integrations.Crm.Hubspot/wwwroot
20+
src/Umbraco.Forms.Integrations.Crm.ActiveCampaign/wwwroot
1921

2022
# User-specific files (MonoDevelop/Xamarin Studio)
2123
*.userprefs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository houses open-source extensions, created for Umbraco Forms, that i
88

99
[Hubspot](./src/Umbraco.Forms.Integrations.Crm.Hubspot/) - a custom workflow allowing form form entries to be mapped to a HubSpot contact record, and stored within the CRM platform.
1010

11-
[ActiveCampaign](./src/Umbraco.Forms.Integrations.Crm.ActiveCampaign/) - a custom workflow allowing form entries to be mapped to an ActiveCampaign contact, and stored withing the CRM platform.
11+
[ActiveCampaign](./src/Umbraco.Forms.Integrations.Crm.ActiveCampaign/) - a custom workflow allowing form entries to be mapped to an ActiveCampaign contact, and stored within the CRM platform.
1212

1313
### Automation
1414

src/Umbraco.Forms.Integrations.Crm.ActiveCampaign/ActiveCampaignComposer.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.Extensions.DependencyInjection;
2-
2+
using Microsoft.OpenApi.Models;
3+
using Swashbuckle.AspNetCore.SwaggerGen;
34
using Umbraco.Cms.Core.Composing;
45
using Umbraco.Cms.Core.DependencyInjection;
56
using Umbraco.Forms.Core.Providers;
@@ -30,6 +31,21 @@ public void Compose(IUmbracoBuilder builder)
3031

3132
builder.Services.AddSingleton<IAccountService, AccountService>();
3233
builder.Services.AddSingleton<IContactService, ContactService>();
34+
35+
// Generate Swagger documentation for Zapier API
36+
builder.Services.Configure<SwaggerGenOptions>(options =>
37+
{
38+
options.SwaggerDoc(
39+
Constants.ManagementApi.ApiName,
40+
new OpenApiInfo
41+
{
42+
Title = Constants.ManagementApi.ApiTitle,
43+
Version = "Latest",
44+
Description = $"Describes the {Constants.ManagementApi.ApiTitle} available for handling ActiveCampaign automation and configuration."
45+
});
46+
47+
options.CustomOperationIds(e => $"{e.ActionDescriptor.RouteValues["action"]}");
48+
});
3349
}
3450
}
3551
}

src/Umbraco.Forms.Integrations.Crm.ActiveCampaign/ActiveCampaignContactsWorkflow.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Microsoft.Extensions.Logging;
22
using Microsoft.Extensions.Options;
3-
43
using System.Text.Json;
5-
64
using Umbraco.Forms.Core;
75
using Umbraco.Forms.Core.Enums;
86
using Umbraco.Forms.Core.Persistence.Dtos;
@@ -24,17 +22,17 @@ public class ActiveCampaignContactsWorkflow : WorkflowType
2422

2523
[Core.Attributes.Setting("Account",
2624
Description = "Please select an account",
27-
View = "~/App_Plugins/UmbracoForms.Integrations/Crm/ActiveCampaign/accountpicker.html")]
25+
View = "ActiveCampaign.Contacts.PropertyEditorUi.Account")]
2826
public string Account { get; set; }
2927

3028
[Core.Attributes.Setting("Contact Mappings",
3129
Description = "Map contact details with form fields",
32-
View = "~/App_Plugins/UmbracoForms.Integrations/Crm/ActiveCampaign/contact-mapper.html")]
30+
View = "ActiveCampaign.Contacts.PropertyEditorUi.ContactMapping")]
3331
public string ContactMappings { get; set; }
3432

3533
[Core.Attributes.Setting("Custom Field Mappings",
3634
Description = "Map contact custom fields with form fields",
37-
View = "~/App_Plugins/UmbracoForms.Integrations/Crm/ActiveCampaign/customfield-mapper.html")]
35+
View = "ActiveCampaign.Contacts.PropertyEditorUi.CustomMapping")]
3836
public string CustomFieldMappings { get; set; }
3937

4038
public ActiveCampaignContactsWorkflow(IOptions<ActiveCampaignSettings> options,
@@ -55,7 +53,7 @@ public ActiveCampaignContactsWorkflow(IOptions<ActiveCampaignSettings> options,
5553
_logger = logger;
5654
}
5755

58-
public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context)
56+
public override async Task<WorkflowExecutionStatus> ExecuteAsync(WorkflowExecutionContext context)
5957
{
6058
try
6159
{
@@ -65,7 +63,7 @@ public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context
6563
.ValuesAsString();
6664

6765
// Check if contact exists.
68-
var contacts = _contactService.Get(email).ConfigureAwait(false).GetAwaiter().GetResult();
66+
var contacts = await _contactService.Get(email);
6967

7068
if(contacts.Contacts.Count > 0 && !_settings.AllowContactUpdate)
7169
{
@@ -90,8 +88,7 @@ public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context
9088
}).ToList();
9189
}
9290

93-
var contactId = _contactService.CreateOrUpdate(requestDto, contacts.Contacts.Count > 0)
94-
.ConfigureAwait(false).GetAwaiter().GetResult();
91+
var contactId = await _contactService.CreateOrUpdate(requestDto, contacts.Contacts.Count > 0);
9592

9693
if (string.IsNullOrEmpty(contactId))
9794
{
@@ -103,8 +100,7 @@ public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context
103100
// Associate contact with account if last one is specified.
104101
if (!string.IsNullOrEmpty(Account))
105102
{
106-
var associationResponse = _accountService.CreateAssociation(int.Parse(Account), int.Parse(contactId))
107-
.ConfigureAwait(false).GetAwaiter().GetResult();
103+
var associationResponse = _accountService.CreateAssociation(int.Parse(Account), int.Parse(contactId));
108104
}
109105

110106
return WorkflowExecutionStatus.Completed;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Umbraco.Cms.Web.Common.Routing;
4+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Services;
5+
6+
namespace Umbraco.Forms.Integrations.Crm.ActiveCampaign.Api.Management.Controllers.Accounts
7+
{
8+
[ApiVersion("1.0")]
9+
[BackOfficeRoute($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}/accounts")]
10+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.AccountsGroupName)]
11+
public class AccountControllerBase : ActiveCampaignControllerBase
12+
{
13+
protected readonly IAccountService _accountService;
14+
15+
public AccountControllerBase(IAccountService accountService)
16+
{
17+
_accountService = accountService;
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Umbraco.Cms.Web.Common.Authorization;
5+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Models.Dtos;
6+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Services;
7+
8+
namespace Umbraco.Forms.Integrations.Crm.ActiveCampaign.Api.Management.Controllers.Accounts
9+
{
10+
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
11+
public class GetAccountController : AccountControllerBase
12+
{
13+
public GetAccountController(IAccountService accountService) : base(accountService)
14+
{
15+
}
16+
17+
[HttpGet]
18+
[ProducesResponseType(typeof(AccountCollectionResponseDto), StatusCodes.Status200OK)]
19+
public async Task<IActionResult> GetAccounts()
20+
{
21+
var accounts = await _accountService.Get();
22+
23+
return Ok(accounts);
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Umbraco.Cms.Api.Common.Attributes;
4+
using Umbraco.Cms.Web.Common.Authorization;
5+
6+
namespace Umbraco.Forms.Integrations.Crm.ActiveCampaign.Api.Management.Controllers
7+
{
8+
[ApiController]
9+
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
10+
[MapToApi(Constants.ManagementApi.ApiName)]
11+
public class ActiveCampaignControllerBase : Controller
12+
{
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Umbraco.Cms.Web.Common.Authorization;
6+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Configuration;
7+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Models.Dtos;
8+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Services;
9+
10+
namespace Umbraco.Forms.Integrations.Crm.ActiveCampaign.Api.Management.Controllers.Contacts
11+
{
12+
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
13+
public class CheckApiAccessController : ContactControllerBase
14+
{
15+
public CheckApiAccessController(IOptions<ActiveCampaignSettings> options, IContactService contactService) : base(options, contactService)
16+
{
17+
}
18+
19+
[HttpGet("api-access")]
20+
[ProducesResponseType(typeof(ApiAccessDto), StatusCodes.Status200OK)]
21+
public IActionResult CheckApiAccess() => Ok(new ApiAccessDto(_settings.BaseUrl, _settings.ApiKey));
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using Umbraco.Cms.Web.Common.Routing;
5+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Configuration;
6+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Services;
7+
8+
namespace Umbraco.Forms.Integrations.Crm.ActiveCampaign.Api.Management.Controllers.Contacts
9+
{
10+
[ApiVersion("1.0")]
11+
[BackOfficeRoute($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}/contacts")]
12+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.ContactGroupName)]
13+
public class ContactControllerBase : ActiveCampaignControllerBase
14+
{
15+
protected readonly ActiveCampaignSettings _settings;
16+
17+
protected readonly IContactService _contactService;
18+
19+
public ContactControllerBase(IOptions<ActiveCampaignSettings> options, IContactService contactService)
20+
{
21+
_settings = options.Value;
22+
23+
_contactService = contactService;
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using Umbraco.Cms.Web.Common.Authorization;
11+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Configuration;
12+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Models.Dtos;
13+
using Umbraco.Forms.Integrations.Crm.ActiveCampaign.Services;
14+
15+
namespace Umbraco.Forms.Integrations.Crm.ActiveCampaign.Api.Management.Controllers.Contacts
16+
{
17+
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
18+
public class GetContactFieldsController : ContactControllerBase
19+
{
20+
public GetContactFieldsController(IOptions<ActiveCampaignSettings> options, IContactService contactService) : base(options, contactService)
21+
{
22+
}
23+
24+
[HttpGet("fields")]
25+
[ProducesResponseType(typeof(List<ContactFieldSettings>), StatusCodes.Status200OK)]
26+
public IActionResult GetContactFields() => Ok(_settings.ContactFields);
27+
}
28+
}

0 commit comments

Comments
 (0)