Skip to content

Commit 211a740

Browse files
committed
42083 V14-Integrations-Shopify
- Update project
1 parent 3c5e282 commit 211a740

File tree

73 files changed

+3022
-90
lines changed

Some content is hidden

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

73 files changed

+3022
-90
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Asp.Versioning;
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.Integrations.Commerce.Shopify.Configuration;
11+
using Umbraco.Cms.Integrations.Commerce.Shopify.Core.Api.Management.Controllers;
12+
using Umbraco.Cms.Integrations.Commerce.Shopify.Models.Dtos;
13+
14+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Core.New.Api.Management.Controllers
15+
{
16+
[ApiVersion("1.0")]
17+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
18+
public class GetAllController : ShopifyControllerBase
19+
{
20+
protected GetAllController(IOptions<ShopifySettings> shopifySettings) : base(shopifySettings)
21+
{
22+
}
23+
24+
[HttpGet]
25+
[ProducesResponseType(typeof(ProductDto), StatusCodes.Status200OK)]
26+
public async Task GetAll()
27+
{
28+
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Microsoft.Extensions.Options;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Umbraco.Cms.Integrations.Commerce.Shopify.Configuration;
8+
using Umbraco.Cms.Integrations.Commerce.Shopify.Core.Api.Management.Controllers;
9+
10+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Core.New.Api.Management.Controllers
11+
{
12+
public class GetAllOAuthController : ShopifyControllerBase
13+
{
14+
protected GetAllOAuthController(IOptions<ShopifySettings> shopifySettings) : base(shopifySettings)
15+
{
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Extensions.Options;
4+
using System.Collections.Generic;
5+
using System.Net.Http.Headers;
6+
using System.Net.Http;
7+
using System;
8+
using Umbraco.Cms.Api.Common.Attributes;
9+
using Umbraco.Cms.Web.Common.Authorization;
10+
using Umbraco.Cms.Web.Common.Routing;
11+
using System.Linq;
12+
using Umbraco.Cms.Integrations.Commerce.Shopify.Configuration;
13+
14+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Core.Api.Management.Controllers
15+
{
16+
[ApiController]
17+
[BackOfficeRoute($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}/shopify")]
18+
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
19+
[MapToApi(Constants.ManagementApi.ApiName)]
20+
public abstract class ShopifyControllerBase : Controller
21+
{
22+
protected const string ShopifyApiEndpoint = "https://admin.shopify.com";
23+
protected ShopifySettings ShopifySettings;
24+
25+
protected ShopifyControllerBase(IOptions<ShopifySettings> shopifySettings)
26+
{
27+
ShopifySettings = shopifySettings.Value;
28+
}
29+
30+
protected HttpRequestMessage CreateRequest(string accessToken)
31+
{
32+
var requestMessage = new HttpRequestMessage
33+
{
34+
Method = HttpMethod.Get,
35+
RequestUri = new Uri(ShopifyApiEndpoint)
36+
};
37+
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
38+
return requestMessage;
39+
}
40+
}
41+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Collections.Specialized;
2+
3+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Configuration
4+
{
5+
public class ShopifyOAuthSettings
6+
{
7+
public ShopifyOAuthSettings() { }
8+
9+
public ShopifyOAuthSettings(NameValueCollection appSettings)
10+
{
11+
ClientId = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyClientIdKey];
12+
13+
ClientSecret = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyClientSecretKey];
14+
15+
RedirectUri = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyRedirectUriKey];
16+
17+
Scopes = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyScopesKey];
18+
19+
TokenEndpoint = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyTokenEndpointKey];
20+
}
21+
22+
public string ClientId { get; set; }
23+
24+
public string ClientSecret { get; set; }
25+
26+
public string RedirectUri { get; set; }
27+
28+
public string Scopes { get; set; }
29+
30+
public string TokenEndpoint { get; set; }
31+
}
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Specialized;
2+
3+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Configuration
4+
{
5+
public class ShopifySettings
6+
{
7+
public ShopifySettings()
8+
{
9+
10+
}
11+
12+
public ShopifySettings(NameValueCollection appSettings)
13+
{
14+
ApiVersion = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyApiVersion];
15+
Shop = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyShop];
16+
AccessToken = appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyAccessToken];
17+
UseUmbracoAuthorization = bool.TryParse(appSettings[Constants.Configuration.UmbracoCmsIntegrationsCommerceShopifyUseUmbracoAuthorizationKey], out var key)
18+
? key
19+
: true;
20+
}
21+
22+
public string ApiVersion { get; set; }
23+
24+
public string Shop { get; set; }
25+
26+
public string AccessToken { get; set; }
27+
28+
public bool UseUmbracoAuthorization { get; set; } = true;
29+
}
30+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+

2+
namespace Umbraco.Cms.Integrations.Commerce.Shopify
3+
{
4+
public static class Constants
5+
{
6+
public const string AppPluginFolderPath = "~/App_Plugins/UmbracoCms.Integrations/Commerce/Shopify";
7+
8+
public const string AccessTokenDbKey = "Umbraco.Cms.Integrations.Shopify.AccessTokenDbKey";
9+
10+
public const string ProductsApiEndpoint = "https://{0}.myshopify.com/admin/api/{1}/products.json";
11+
12+
public const string ProductsCountApiEndpoint = "https://{0}.myshopify.com/admin/api/{1}/products/count.json";
13+
14+
public const int DEFAULT_PAGE_SIZE = 10;
15+
16+
public static class RenderingComponent
17+
{
18+
public const string DefaultV8ViewPath = AppPluginFolderPath + "/Render/Products.cshtml";
19+
20+
public const string DefaultV9ViewPath = AppPluginFolderPath + "/Render/ProductsV9.cshtml";
21+
}
22+
23+
public static class ManagementApi
24+
{
25+
public const string RootPath = "shopify/management/api";
26+
27+
public const string ApiTitle = "Shopify Management API";
28+
29+
public const string ApiName = "shopify-management";
30+
31+
public const string GroupName = "Shopify";
32+
}
33+
34+
public static class Configuration
35+
{
36+
public const string Settings = "Umbraco:Cms:Integrations:Commerce:Shopify:Settings";
37+
38+
public const string OAuthSettings = "Umbraco:Cms:Integrations:Commerce:Shopify:OAuthSettings";
39+
40+
public const string UmbracoCmsIntegrationsCommerceShopifyApiVersion =
41+
"Umbraco.Cms.Integrations.Commerce.Shopify.ApiVersion";
42+
43+
public const string UmbracoCmsIntegrationsCommerceShopifyShop =
44+
"Umbraco.Cms.Integrations.Commerce.Shopify.Shop";
45+
46+
public const string UmbracoCmsIntegrationsCommerceShopifyAccessToken =
47+
"Umbraco.Cms.Integrations.Commerce.Shopify.AccessToken";
48+
49+
public const string UmbracoCmsIntegrationsCommerceShopifyUseUmbracoAuthorizationKey =
50+
"Umbraco.Cms.Integrations.Commerce.Shopify.UseUmbracoAuthorization";
51+
52+
public const string UmbracoCmsIntegrationsCommerceShopifyClientIdKey = "Umbraco.Cms.Integrations.Commerce.Shopify.ClientId";
53+
54+
public const string UmbracoCmsIntegrationsCommerceShopifyClientSecretKey = "Umbraco.Cms.Integrations.Commerce.Shopify.ClientSecret";
55+
56+
public const string UmbracoCmsIntegrationsCommerceShopifyRedirectUriKey = "Umbraco.Cms.Integrations.Commerce.Shopify.RedirectUri";
57+
58+
public const string UmbracoCmsIntegrationsCommerceShopifyScopesKey = "Umbraco.Cms.Integrations.Commerce.Shopify.Scopes";
59+
60+
public const string UmbracoCmsIntegrationsCommerceShopifyTokenEndpointKey = "Umbraco.Cms.Integrations.Commerce.Shopify.TokenEndpoint";
61+
}
62+
63+
public static class PropertyEditors
64+
{
65+
public const string ProductPickerAlias = "Umbraco.Cms.Integrations.Commerce.Shopify.ProductPicker";
66+
}
67+
}
68+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//using System.Threading.Tasks;
2+
3+
//using Umbraco.Cms.Integrations.Commerce.Shopify.Models;
4+
//using Umbraco.Cms.Integrations.Commerce.Shopify.Models.Dtos;
5+
//using Umbraco.Cms.Integrations.Commerce.Shopify.Services;
6+
//using Umbraco.Cms.Integrations.Commerce.Shopify.Configuration;
7+
8+
//using static Umbraco.Cms.Integrations.Commerce.Shopify.ShopifyComposer;
9+
//using System.Linq;
10+
11+
12+
//#if NETCOREAPP
13+
//using Microsoft.Extensions.Options;
14+
//using Microsoft.AspNetCore.Mvc;
15+
16+
//using Umbraco.Cms.Web.BackOffice.Controllers;
17+
//using Umbraco.Cms.Web.Common.Attributes;
18+
//#else
19+
//using System.Configuration;
20+
//using System.Web.Http;
21+
22+
//using Umbraco.Web.Mvc;
23+
//using Umbraco.Web.WebApi;
24+
//#endif
25+
26+
//namespace Umbraco.Cms.Integrations.Commerce.Shopify.Controllers
27+
//{
28+
// [PluginController("UmbracoCmsIntegrationsCommerceShopify")]
29+
// public class ProductsController : UmbracoAuthorizedApiController
30+
// {
31+
// private readonly ShopifySettings _settings;
32+
33+
// private readonly IShopifyAuthorizationService _authorizationService;
34+
35+
// private readonly IShopifyService _apiService;
36+
37+
//#if NETCOREAPP
38+
// public ProductsController(IOptions<ShopifySettings> options, IShopifyService apiService, AuthorizationImplementationFactory authorizationImplementationFactory)
39+
//#else
40+
// public ProductsController(IShopifyService apiService, AuthorizationImplementationFactory authorizationImplementationFactory)
41+
//#endif
42+
// {
43+
//#if NETCOREAPP
44+
// _settings = options.Value;
45+
//#else
46+
// _settings = new ShopifySettings(ConfigurationManager.AppSettings);
47+
//#endif
48+
// _apiService = apiService;
49+
// _authorizationService = authorizationImplementationFactory(_settings.UseUmbracoAuthorization);
50+
// }
51+
52+
// [HttpGet]
53+
// public EditorSettings CheckConfiguration() => _apiService.GetApiConfiguration();
54+
55+
// [HttpGet]
56+
// public string GetAuthorizationUrl() => _authorizationService.GetAuthorizationUrl();
57+
58+
// [HttpPost]
59+
// public async Task<string> GetAccessToken([FromBody] OAuthRequestDto authRequestDto) =>
60+
// await _authorizationService.GetAccessTokenAsync(authRequestDto.Code);
61+
62+
// [HttpGet]
63+
// public async Task<ResponseDto<ProductsListDto>> ValidateAccessToken() => await _apiService.ValidateAccessToken();
64+
65+
// [HttpPost]
66+
// public void RevokeAccessToken() => _apiService.RevokeAccessToken();
67+
68+
// public async Task<ResponseDto<ProductsListDto>> GetList(string pageInfo) => await _apiService.GetResults(pageInfo);
69+
70+
// public async Task<ResponseDto<ProductsListDto>> GetListByIds([FromBody] RequestDto dto) =>
71+
// await _apiService.GetProductsByIds(dto.Ids.Select(p => (long.Parse(p))).ToArray());
72+
73+
// [HttpGet]
74+
// public async Task<int> GetTotalPages()
75+
// {
76+
// var productsCount = await _apiService.GetCount();
77+
78+
// return productsCount / Constants.DEFAULT_PAGE_SIZE + 1;
79+
// }
80+
// }
81+
//}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//using Umbraco.Cms.Integrations.Commerce.Shopify.Models;
2+
3+
//#if NETCOREAPP
4+
//using Microsoft.AspNetCore.Mvc;
5+
6+
//using Umbraco.Cms.Web.Common.Controllers;
7+
//#else
8+
//using System.Web.Http;
9+
//using System.Net.Http;
10+
//using System.Net.Http.Headers;
11+
12+
//using Umbraco.Web.WebApi;
13+
//#endif
14+
15+
//namespace Umbraco.Cms.Integrations.Commerce.Shopify.Controllers
16+
//{
17+
// public class ShopifyAuthorizationController : UmbracoApiController
18+
// {
19+
// [HttpGet]
20+
//#if NETCOREAPP
21+
// public IActionResult OAuth(string code)
22+
// {
23+
// return new ContentResult
24+
// {
25+
// Content = string.IsNullOrEmpty(code)
26+
// ? JavascriptResponse.Fail("Authorization process failed.")
27+
// : JavascriptResponse.Ok(code),
28+
// ContentType = "text/html"
29+
// };
30+
// }
31+
//#else
32+
// public HttpResponseMessage OAuth(string code)
33+
// {
34+
// var response = new HttpResponseMessage();
35+
// response.Content = new StringContent(string.IsNullOrEmpty(code)
36+
// ? JavascriptResponse.Fail("Authorization process failed.")
37+
// : JavascriptResponse.Ok(code));
38+
// response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
39+
// return response;
40+
// }
41+
//#endif
42+
// }
43+
//}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//using Umbraco.Cms.Integrations.Commerce.Shopify.Models;
2+
3+
//#if NETCOREAPP
4+
//using Umbraco.Cms.Core.PropertyEditors;
5+
//#else
6+
//using Umbraco.Core.PropertyEditors;
7+
//#endif
8+
9+
//namespace Umbraco.Cms.Integrations.Commerce.Shopify.Editors
10+
//{
11+
// public class ShopifyProductPickerConfiguration
12+
// {
13+
// [ConfigurationField(
14+
// key: "productPickerSettings",
15+
// name: "Settings",
16+
// view: "~/App_Plugins/UmbracoCms.Integrations/Commerce/Shopify/views/productPickerSettings.html")]
17+
// public ProductPickerSettings ProductPickerSettings { get; set; }
18+
19+
// [ConfigurationField("validationLimit", "Amount", "numberrange", Description = "Set a required range of items selected")]
20+
// public NumberRange ValidationLimit { get; set; } = new NumberRange();
21+
// }
22+
//}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//#if NETCOREAPP
2+
//using Umbraco.Cms.Core.IO;
3+
//using Umbraco.Cms.Core.PropertyEditors;
4+
//#else
5+
//using Umbraco.Core.PropertyEditors;
6+
//#endif
7+
8+
//namespace Umbraco.Cms.Integrations.Commerce.Shopify.Editors
9+
//{
10+
// public class ShopifyProductPickerConfigurationEditor: ConfigurationEditor<ShopifyProductPickerConfiguration>
11+
// {
12+
//#if NETCOREAPP
13+
// public ShopifyProductPickerConfigurationEditor(IIOHelper ioHelper) : base(ioHelper)
14+
// {
15+
// }
16+
//#endif
17+
// }
18+
//}

0 commit comments

Comments
 (0)