Skip to content

Commit 8cb83c7

Browse files
authored
Merge pull request #205 from umbraco/v14/feature/42660-V14-Integrations-(Dynamics)
V14: Integrations (Dynamics)
2 parents 93eb6bb + 9759be0 commit 8cb83c7

File tree

103 files changed

+9195
-1275
lines changed

Some content is hidden

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

103 files changed

+9195
-1275
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ src/Testsite/App_Plugins/Our.Umbraco.DashIt
66
src/Testsite/umbraco
77
src/Testsite/Views
88
src/Testsite/wwwroot
9+
src/Umbraco.Cms.Integrations.Commerce.Shopify/wwwroot/*
10+
!src/Umbraco.Cms.Integrations.Commerce.Shopify/wwwroot/umbraco-package.json
11+
src/Umbraco.Cms.Integrations.Crm.Hubspot/wwwroot/*
12+
!src/Umbraco.Cms.Integrations.Crm.Hubspot/wwwroot/umbraco-package.json
13+
src/Umbraco.Cms.Integrations.Crm.Dynamics/wwwroot/*
14+
!src/Umbraco.Cms.Integrations.Crm.Dynamics/wwwroot/umbraco-package.json
915
src/Umbraco.Cms.Integrations.Automation.Zapier/wwwroot
1016
src/Umbraco.Cms.Integrations.Commerce.Shopify/wwwroot
1117
src/Umbraco.Cms.Integrations.Crm.Hubspot/wwwroot
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const outputPath = 'Release' !== 'Release' ? '../wwwroot' : '../obj/Release/net8.0/clientassets'
1+
export const outputPath = 'Debug' !== 'Release' ? '../wwwroot' : '../obj/Debug/net8.0/clientassets'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using Umbraco.Cms.Integrations.Crm.Dynamics.Configuration;
5+
using Umbraco.Cms.Integrations.Crm.Dynamics.Models.Dtos;
6+
using Umbraco.Cms.Integrations.Crm.Dynamics.Services;
7+
8+
namespace Umbraco.Cms.Integrations.Crm.Dynamics.Api.Management.Controllers
9+
{
10+
public class CheckOAuthConfigurationController : FormsControllerBase
11+
{
12+
public CheckOAuthConfigurationController(
13+
IOptions<DynamicsSettings> options,
14+
IDynamicsService dynamicsService,
15+
IDynamicsConfigurationStorage dynamicsConfigurationStorage,
16+
DynamicsComposer.AuthorizationImplementationFactory authorizationImplementationFactory)
17+
: base(options, dynamicsService, dynamicsConfigurationStorage, authorizationImplementationFactory)
18+
{
19+
}
20+
21+
[HttpGet("oauth-configuration")]
22+
[ProducesResponseType(typeof(OAuthConfigurationDto), StatusCodes.Status200OK)]
23+
public async Task<IActionResult> CheckOAuthConfiguration()
24+
{
25+
var oauthConfiguration = DynamicsConfigurationStorage.GetOAuthConfiguration();
26+
27+
if (oauthConfiguration == null) return Ok(new OAuthConfigurationDto { Message = string.Empty });
28+
29+
var identity = await DynamicsService.GetIdentity(oauthConfiguration.AccessToken);
30+
31+
if (!identity.IsAuthorized) return Ok(new OAuthConfigurationDto { Message = identity.Error != null ? identity.Error.Message : string.Empty });
32+
33+
oauthConfiguration.IsAuthorized = true;
34+
35+
return Ok(oauthConfiguration);
36+
}
37+
}
38+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Umbraco.Cms.Api.Common.Attributes;
3+
using Umbraco.Cms.Web.Common.Routing;
4+
5+
namespace Umbraco.Cms.Integrations.Crm.Dynamics.Api.Management.Controllers
6+
{
7+
[ApiController]
8+
[BackOfficeRoute($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}")]
9+
[MapToApi(Constants.ManagementApi.ApiName)]
10+
public class DynamicsControllerBase : Controller
11+
{
12+
}
13+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using Umbraco.Cms.Integrations.Crm.Dynamics.Configuration;
5+
using Umbraco.Cms.Integrations.Crm.Dynamics.Services;
6+
using static Umbraco.Cms.Integrations.Crm.Dynamics.DynamicsComposer;
7+
8+
namespace Umbraco.Cms.Integrations.Crm.Dynamics.Api.Management.Controllers
9+
{
10+
[ApiVersion("1.0")]
11+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
12+
[Route($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}/forms")]
13+
public class FormsControllerBase : DynamicsControllerBase
14+
{
15+
protected readonly DynamicsSettings DynamicsSettings;
16+
17+
protected readonly IDynamicsAuthorizationService AuthorizationService;
18+
19+
protected readonly IDynamicsService DynamicsService;
20+
21+
protected readonly IDynamicsConfigurationStorage DynamicsConfigurationStorage;
22+
23+
public FormsControllerBase(IOptions<DynamicsSettings> options,
24+
IDynamicsService dynamicsService,
25+
IDynamicsConfigurationStorage dynamicsConfigurationStorage,
26+
AuthorizationImplementationFactory authorizationImplementationFactory)
27+
{
28+
29+
DynamicsSettings = options.Value;
30+
31+
AuthorizationService = authorizationImplementationFactory(DynamicsSettings.UseUmbracoAuthorization);
32+
33+
DynamicsService = dynamicsService;
34+
35+
DynamicsConfigurationStorage = dynamicsConfigurationStorage;
36+
}
37+
}
38+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using Umbraco.Cms.Integrations.Crm.Dynamics.Configuration;
5+
using Umbraco.Cms.Integrations.Crm.Dynamics.Models.Dtos;
6+
using Umbraco.Cms.Integrations.Crm.Dynamics.Services;
7+
8+
namespace Umbraco.Cms.Integrations.Crm.Dynamics.Api.Management.Controllers
9+
{
10+
public class GetAccessTokenController : FormsControllerBase
11+
{
12+
public GetAccessTokenController(
13+
IOptions<DynamicsSettings> options,
14+
IDynamicsService dynamicsService,
15+
IDynamicsConfigurationStorage dynamicsConfigurationStorage,
16+
DynamicsComposer.AuthorizationImplementationFactory authorizationImplementationFactory)
17+
: base(options, dynamicsService, dynamicsConfigurationStorage, authorizationImplementationFactory)
18+
{
19+
}
20+
21+
[HttpPost("access-token")]
22+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
23+
public async Task<IActionResult> GetAccessToken([FromBody] OAuthRequestDto authRequestDto) =>
24+
Ok(await AuthorizationService.GetAccessTokenAsync(authRequestDto.Code));
25+
}
26+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using Umbraco.Cms.Integrations.Crm.Dynamics.Configuration;
5+
using Umbraco.Cms.Integrations.Crm.Dynamics.Services;
6+
7+
namespace Umbraco.Cms.Integrations.Crm.Dynamics.Api.Management.Controllers
8+
{
9+
public class GetAuthorizationUrlController : FormsControllerBase
10+
{
11+
public GetAuthorizationUrlController(
12+
IOptions<DynamicsSettings> options,
13+
IDynamicsService dynamicsService,
14+
IDynamicsConfigurationStorage dynamicsConfigurationStorage,
15+
DynamicsComposer.AuthorizationImplementationFactory authorizationImplementationFactory)
16+
: base(options, dynamicsService, dynamicsConfigurationStorage, authorizationImplementationFactory)
17+
{
18+
}
19+
20+
[HttpGet("authorization-url")]
21+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
22+
public IActionResult GetAuthorizationUrl()
23+
{
24+
var url = AuthorizationService.GetAuthorizationUrl();
25+
return Ok(url);
26+
}
27+
}
28+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using Umbraco.Cms.Integrations.Crm.Dynamics.Configuration;
5+
using Umbraco.Cms.Integrations.Crm.Dynamics.Services;
6+
7+
namespace Umbraco.Cms.Integrations.Crm.Dynamics.Api.Management.Controllers
8+
{
9+
public class GetEmbedCodeController : FormsControllerBase
10+
{
11+
public GetEmbedCodeController(
12+
IOptions<DynamicsSettings> options,
13+
IDynamicsService dynamicsService,
14+
IDynamicsConfigurationStorage dynamicsConfigurationStorage,
15+
DynamicsComposer.AuthorizationImplementationFactory authorizationImplementationFactory)
16+
: base(options, dynamicsService, dynamicsConfigurationStorage, authorizationImplementationFactory)
17+
{
18+
}
19+
20+
[HttpGet("embed-code")]
21+
[ProducesResponseType(typeof(Task<string>), StatusCodes.Status200OK)]
22+
public async Task<IActionResult> GetEmbedCode(string formId) => Ok(await DynamicsService.GetEmbedCode(formId));
23+
}
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using Umbraco.Cms.Integrations.Crm.Dynamics.Configuration;
5+
using Umbraco.Cms.Integrations.Crm.Dynamics.Models;
6+
using Umbraco.Cms.Integrations.Crm.Dynamics.Models.Dtos;
7+
using Umbraco.Cms.Integrations.Crm.Dynamics.Services;
8+
9+
namespace Umbraco.Cms.Integrations.Crm.Dynamics.Api.Management.Controllers
10+
{
11+
public class GetFormsController : FormsControllerBase
12+
{
13+
public GetFormsController(
14+
IOptions<DynamicsSettings> options,
15+
IDynamicsService dynamicsService,
16+
IDynamicsConfigurationStorage dynamicsConfigurationStorage,
17+
DynamicsComposer.AuthorizationImplementationFactory authorizationImplementationFactory)
18+
: base(options, dynamicsService, dynamicsConfigurationStorage, authorizationImplementationFactory)
19+
{
20+
}
21+
22+
[HttpGet]
23+
[ProducesResponseType(typeof(IEnumerable<FormDto>), StatusCodes.Status200OK)]
24+
public async Task<IActionResult> GetForms(string module) =>
25+
Ok(await DynamicsService.GetForms((DynamicsModule)Enum.Parse(typeof(DynamicsModule), module)));
26+
}
27+
}

0 commit comments

Comments
 (0)