Skip to content

Commit 53f3fa4

Browse files
committed
Update API endpoints and client references
1 parent 54baaf6 commit 53f3fa4

15 files changed

+160
-191
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Umbraco.Cms.Integrations.Automation.Zapier.Configuration;
6+
using Umbraco.Cms.Integrations.Automation.Zapier.Helpers;
7+
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
8+
9+
namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
10+
{
11+
[ApiVersion("1.0")]
12+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
13+
public class CheckFormExtensionController : ZapierControllerBase
14+
{
15+
public CheckFormExtensionController(IOptions<ZapierSettings> options, IUserValidationService userValidationService)
16+
: base(options, userValidationService)
17+
{
18+
}
19+
20+
[HttpGet("check-form-extension")]
21+
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
22+
public IActionResult CheckFormsExtensionInstalled() => Ok(ReflectionHelper.IsFormsExtensionInstalled);
23+
}
24+
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/ConfigController.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/PollingController.cs renamed to src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/GetContentByTypeController.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.Options;
5-
using Umbraco.Cms.Core.Models.PublishedContent;
65
using Umbraco.Cms.Core.Services;
7-
using Umbraco.Cms.Web.Common;
86
using Umbraco.Cms.Integrations.Automation.Zapier.Configuration;
9-
using Asp.Versioning;
10-
using Microsoft.AspNetCore.Mvc;
7+
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
8+
using Umbraco.Cms.Web.Common;
119
using Umbraco.Extensions;
12-
using Microsoft.AspNetCore.Http;
1310

1411
namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
1512
{
@@ -20,15 +17,15 @@ namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
2017
/// </summary>
2118
[ApiVersion("1.0")]
2219
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
23-
public class PollingController : ZapierControllerBase
20+
public class GetContentByTypeController : ZapierControllerBase
2421
{
2522
private readonly IContentTypeService _contentTypeService;
2623

2724
private readonly IZapierContentService _zapierContentService;
2825

2926
private readonly UmbracoHelper _umbracoHelper;
3027

31-
public PollingController(
28+
public GetContentByTypeController(
3229
IOptions<ZapierSettings> options,
3330
IContentService contentService,
3431
IContentTypeService contentTypeService,
@@ -42,21 +39,22 @@ public PollingController(
4239
_umbracoHelper = umbracoHelper;
4340
}
4441

45-
[HttpGet("content-by-type")]
42+
[HttpGet("content-type/{alias}/content")]
4643
[ProducesResponseType(typeof(List<Dictionary<string, string>>), StatusCodes.Status200OK)]
47-
[ProducesResponseType(StatusCodes.Status404NotFound)]
48-
public IActionResult GetContentByType(string alias)
44+
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
45+
public IActionResult GetContentByContentType(string alias)
4946
{
5047
if (!IsAccessValid())
51-
return NotFound();
48+
return Unauthorized();
5249

5350
var contentType = _contentTypeService.Get(alias);
5451
if (contentType == null)
5552
return Ok(new List<Dictionary<string, string>>());
5653

5754
var contentItems = _umbracoHelper.ContentAtRoot().DescendantsOrSelfOfType(alias)
5855
.OrderByDescending(p => p.UpdateDate);
59-
var contentTypeDictionary = new List<Dictionary<string, string>>{
56+
var contentTypeDictionary = new List<Dictionary<string, string>>
57+
{
6058
_zapierContentService.GetContentTypeDictionary(contentType, contentItems.FirstOrDefault())
6159
};
6260

src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/ContentController.cs renamed to src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/GetContentTypesController.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
using Umbraco.Cms.Integrations.Automation.Zapier.Models.Dtos;
4-
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
54
using Microsoft.Extensions.Options;
65
using Umbraco.Cms.Core.Services;
76
using Umbraco.Cms.Integrations.Automation.Zapier.Configuration;
8-
using Asp.Versioning;
9-
using Microsoft.AspNetCore.Mvc;
10-
using Microsoft.AspNetCore.Mvc.Formatters.Xml;
11-
using Microsoft.AspNetCore.Http;
7+
using Umbraco.Cms.Integrations.Automation.Zapier.Models.Dtos;
8+
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
129

1310
namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
1411
{
@@ -17,22 +14,22 @@ namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
1714
/// </summary>
1815
[ApiVersion("1.0")]
1916
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
20-
public class ContentController : ZapierControllerBase
17+
public class GetContentTypesController : ZapierControllerBase
2118
{
2219
private readonly IContentTypeService _contentTypeService;
23-
public ContentController(IOptions<ZapierSettings> options, IContentTypeService contentTypeService, IUserValidationService userValidationService)
20+
public GetContentTypesController(IOptions<ZapierSettings> options, IContentTypeService contentTypeService, IUserValidationService userValidationService)
2421
: base(options, userValidationService)
2522
{
2623
_contentTypeService = contentTypeService;
2724
}
2825

2926
[HttpGet("content-types")]
3027
[ProducesResponseType(typeof(IEnumerable<ContentTypeDto>), StatusCodes.Status200OK)]
31-
[ProducesResponseType(StatusCodes.Status404NotFound)]
28+
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
3229
public IActionResult GetContentTypes()
3330
{
3431
if (!IsAccessValid())
35-
return NotFound();
32+
return Unauthorized();
3633

3734
var contentTypes = _contentTypeService.GetAll();
3835
var mapToDto = contentTypes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Umbraco.Cms.Integrations.Automation.Zapier.Configuration;
6+
using Umbraco.Cms.Integrations.Automation.Zapier.Models.Dtos;
7+
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
8+
9+
namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
10+
{
11+
[ApiVersion("1.0")]
12+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
13+
public class GetSubscriptionHookController : ZapierControllerBase
14+
{
15+
private readonly ZapierSubscriptionHookService _zapierSubscriptionHookService;
16+
17+
public GetSubscriptionHookController(
18+
IOptions<ZapierSettings> options,
19+
IUserValidationService userValidationService,
20+
ZapierSubscriptionHookService zapierSubscriptionHookService)
21+
: base(options, userValidationService) => _zapierSubscriptionHookService = zapierSubscriptionHookService;
22+
23+
[HttpGet("subscription-hooks")]
24+
[ProducesResponseType(typeof(IEnumerable<SubscriptionDto>), StatusCodes.Status200OK)]
25+
public IActionResult GetAll() => Ok(_zapierSubscriptionHookService.GetAll());
26+
}
27+
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/SubscriptionController.cs renamed to src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/UpdateSubscriptionHookController.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using System.Collections.Generic;
2-
using Umbraco.Cms.Integrations.Automation.Zapier.Models.Dtos;
3-
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
43
using Microsoft.AspNetCore.Mvc;
54
using Microsoft.Extensions.Options;
65
using Umbraco.Cms.Integrations.Automation.Zapier.Configuration;
7-
using Asp.Versioning;
8-
using Microsoft.AspNetCore.Http;
6+
using Umbraco.Cms.Integrations.Automation.Zapier.Models.Dtos;
7+
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
98

109
namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
1110
{
@@ -14,25 +13,25 @@ namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
1413
/// </summary>
1514
[ApiVersion("1.0")]
1615
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
17-
public class SubscriptionController : ZapierControllerBase
16+
public class UpdateSubscriptionHookController : ZapierControllerBase
1817
{
1918
private readonly ZapierSubscriptionHookService _zapierSubscriptionHookService;
2019

21-
public SubscriptionController(IOptions<ZapierSettings> options,
20+
public UpdateSubscriptionHookController(IOptions<ZapierSettings> options,
2221
ZapierSubscriptionHookService zapierSubscriptionHookService,
2322
IUserValidationService userValidationService)
2423
: base(options, userValidationService)
2524
{
2625
_zapierSubscriptionHookService = zapierSubscriptionHookService;
2726
}
2827

29-
[HttpPost("update-preferences")]
30-
[ProducesResponseType(StatusCodes.Status404NotFound)]
28+
[HttpPost("subscription")]
29+
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
3130
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
3231
public IActionResult UpdatePreferences([FromBody] SubscriptionDto dto)
3332
{
3433
if (!IsAccessValid() || dto == null)
35-
return NotFound();
34+
return Unauthorized();
3635

3736
var result = dto.SubscribeHook
3837
? _zapierSubscriptionHookService.Add(dto.EntityId, dto.Type, dto.HookUrl)

src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/AuthController.cs renamed to src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/ValidateUserController.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
using System.Threading.Tasks;
2-
using Umbraco.Cms.Integrations.Automation.Zapier.Models;
3-
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
43
using Microsoft.AspNetCore.Mvc;
5-
using Umbraco.Cms.Web.Common.Controllers;
6-
using Asp.Versioning;
74
using Microsoft.Extensions.Options;
85
using Umbraco.Cms.Integrations.Automation.Zapier.Configuration;
9-
using Microsoft.AspNetCore.Http;
6+
using Umbraco.Cms.Integrations.Automation.Zapier.Models;
7+
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
108

119
namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
1210
{
@@ -15,16 +13,15 @@ namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
1513
/// </summary>
1614
[ApiVersion("1.0")]
1715
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
18-
public class AuthController : ZapierControllerBase
16+
public class ValidateUserController : ZapierControllerBase
1917
{
20-
21-
public AuthController(IOptions<ZapierSettings> options, IUserValidationService userValidationService) : base(options, userValidationService)
18+
public ValidateUserController(IOptions<ZapierSettings> options, IUserValidationService userValidationService) : base(options, userValidationService)
2219
{
2320
}
2421

2522
[HttpPost("validate-user")]
2623
[ProducesResponseType(typeof(Task<bool>), StatusCodes.Status200OK)]
27-
public async Task<IActionResult> ValidateUser([FromBody] UserModel userModel)
24+
public async Task<IActionResult> Validate([FromBody] UserModel userModel)
2825
{
2926
var result = await _userValidationService.Validate(userModel.Username, userModel.Password, userModel.ApiKey);
3027
return Ok(result);

src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/ZapierControllerBase.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
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-
using Umbraco.Cms.Web.Common.Routing;
6-
using Umbraco.Cms.Integrations.Automation.Zapier.Models;
7-
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
1+
using Microsoft.AspNetCore.Mvc;
82
using Microsoft.Extensions.Options;
3+
using Umbraco.Cms.Api.Common.Attributes;
94
using Umbraco.Cms.Integrations.Automation.Zapier.Configuration;
5+
using Umbraco.Cms.Integrations.Automation.Zapier.Services;
6+
using Umbraco.Cms.Web.Common.Routing;
107

118
namespace Umbraco.Cms.Integrations.Automation.Zapier.Api.Management.Controllers
129
{
1310
[ApiController]
1411
[BackOfficeRoute($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}")]
15-
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
1612
[MapToApi(Constants.ManagementApi.ApiName)]
1713
public class ZapierControllerBase : Controller
1814
{
19-
private readonly ZapierSettings Options;
15+
private readonly ZapierSettings ZapierSettings;
2016

2117
protected IUserValidationService _userValidationService;
2218

2319
public ZapierControllerBase(IOptions<ZapierSettings> options, IUserValidationService userValidationService)
2420
{
25-
Options = options.Value;
21+
ZapierSettings = options.Value;
2622

2723
_userValidationService = userValidationService;
2824
}

0 commit comments

Comments
 (0)