Skip to content

Commit 9127138

Browse files
authored
Merge pull request #200 from umbraco/v14/feature/42083-V14-Integrations-Shopify
V14 integrations: Shopify
2 parents e2c8a6a + 9280d8a commit 9127138

File tree

109 files changed

+8434
-3851
lines changed

Some content is hidden

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

109 files changed

+8434
-3851
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ src/Testsite/App_Plugins/Our.Umbraco.DashIt
66
src/Testsite/umbraco
77
src/Testsite/Views
88
src/Testsite/wwwroot
9-
9+
src/Umbraco.Cms.Integrations.Commerce.Shopify/wwwroot
1010

1111

1212
# User-specific files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Umbraco.Cms.Api.Management.OpenApi;
2+
3+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Configuration;
4+
5+
public class BackOfficeSecurityRequirementsOperationFilter : BackOfficeSecurityRequirementsOperationFilterBase
6+
{
7+
protected override string ApiName => Constants.ManagementApi.ApiName;
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Umbraco.Cms.Integrations.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Models;
7+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
8+
9+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
10+
{
11+
[ApiVersion("1.0")]
12+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
13+
public class CheckConfigurationController : ShopifyControllerBase
14+
{
15+
private readonly ShopifyOAuthSettings _oauthSettings;
16+
public CheckConfigurationController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService, IOptions<ShopifyOAuthSettings> oauthSettings) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
17+
{
18+
_oauthSettings = oauthSettings.Value;
19+
}
20+
21+
[HttpGet("check-configuration")]
22+
[ProducesResponseType(typeof(EditorSettings), StatusCodes.Status200OK)]
23+
public IActionResult CheckConfiguration()
24+
{
25+
var settings = ShopifyService.GetApiConfiguration();
26+
27+
return Ok(settings);
28+
}
29+
}
30+
}
Lines changed: 27 additions & 0 deletions
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.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Models.Dtos;
7+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
8+
9+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
10+
{
11+
[ApiVersion("1.0")]
12+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
13+
public class GetAccessTokenController : ShopifyControllerBase
14+
{
15+
public GetAccessTokenController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
16+
{
17+
}
18+
19+
[HttpPost("access-token")]
20+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
21+
public async Task<IActionResult> GetAccessToken([FromBody]OAuthRequestDto authRequestDto)
22+
{
23+
var setting = await ShopifyAuthorizationService.GetAccessTokenAsync(authRequestDto.Code);
24+
return Ok(setting);
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Umbraco.Cms.Integrations.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
7+
8+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
9+
{
10+
[ApiVersion("1.0")]
11+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
12+
public class GetAuthorizationUrlController : ShopifyControllerBase
13+
{
14+
public GetAuthorizationUrlController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
15+
{
16+
}
17+
18+
[HttpGet("authorization-url")]
19+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
20+
public IActionResult GetAuthorizationUrl()
21+
{
22+
var authUrl = ShopifyAuthorizationService.GetAuthorizationUrl();
23+
return Ok(authUrl);
24+
}
25+
}
26+
}
Lines changed: 27 additions & 0 deletions
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.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Models.Dtos;
7+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
8+
9+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
10+
{
11+
[ApiVersion("1.0")]
12+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
13+
public class GetListByIdsController : ShopifyControllerBase
14+
{
15+
public GetListByIdsController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
16+
{
17+
}
18+
19+
[HttpPost("list-by-ids")]
20+
[ProducesResponseType(typeof(ResponseDto<ProductsListDto>), StatusCodes.Status200OK)]
21+
public async Task<IActionResult> GetListByIds([FromBody] RequestDto dto)
22+
{
23+
var result = await ShopifyService.GetProductsByIds(dto.Ids.Select(p => p).ToArray());
24+
return Ok(result);
25+
}
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
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.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Models.Dtos;
7+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
8+
9+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
10+
{
11+
[ApiVersion("1.0")]
12+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
13+
public class GetListController : ShopifyControllerBase
14+
{
15+
public GetListController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
16+
{
17+
}
18+
19+
[HttpGet("list")]
20+
[ProducesResponseType(typeof(ResponseDto<ProductsListDto>), StatusCodes.Status200OK)]
21+
public async Task<IActionResult> GetList(string? pageInfo)
22+
{
23+
var result = await ShopifyService.GetResults(pageInfo);
24+
return Ok(result);
25+
}
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
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.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
7+
8+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
9+
{
10+
[ApiVersion("1.0")]
11+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
12+
public class GetTotalPagesController : ShopifyControllerBase
13+
{
14+
public GetTotalPagesController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
15+
{
16+
}
17+
18+
[HttpGet("total-pages")]
19+
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
20+
public async Task<IActionResult> GetTotalPages()
21+
{
22+
var productsCount = await ShopifyService.GetCount();
23+
return Ok(productsCount / Constants.DEFAULT_PAGE_SIZE + 1);
24+
}
25+
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Umbraco.Cms.Integrations.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
7+
8+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
9+
{
10+
[ApiVersion("1.0")]
11+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
12+
public class RefreshAccessTokenController : ShopifyControllerBase
13+
{
14+
public RefreshAccessTokenController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
15+
{
16+
}
17+
18+
[HttpPost("refresh-access-token")]
19+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
20+
public async Task<IActionResult> RefreshAccessToken()
21+
{
22+
var response = await ShopifyAuthorizationService.RefreshAccessTokenAsync();
23+
return Ok(response);
24+
}
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Options;
5+
using Umbraco.Cms.Integrations.Commerce.Shopify.Configuration;
6+
using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
7+
8+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Api.Management.Controllers
9+
{
10+
[ApiVersion("1.0")]
11+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
12+
public class RevokeAccessTokenController : ShopifyControllerBase
13+
{
14+
public RevokeAccessTokenController(IOptions<ShopifySettings> shopifySettings, IShopifyService shopifyService, IShopifyAuthorizationService shopifyAuthorizationService) : base(shopifySettings, shopifyService, shopifyAuthorizationService)
15+
{
16+
}
17+
18+
[HttpPost("revoke-access-token")]
19+
[ProducesResponseType(StatusCodes.Status200OK)]
20+
public ActionResult RevokeAccessToken()
21+
{
22+
ShopifyService.RevokeAccessToken();
23+
return Ok();
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)