-
Notifications
You must be signed in to change notification settings - Fork 3
Allow custom FeedGeneratorService implementations #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BenWhite27
wants to merge
17
commits into
umbraco:main
Choose a base branch
from
BenWhite27:feature/extendable-feed-generators
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0f2ab63
Use a CollectionBuilder to register FeedGenerators. Updated Backend …
5335210
Updated Frontend implementation to use FeedGeneratorId instead of Fee…
ec93a31
Provide a mechanism for IProductFeedGeneratrorService implementations…
33f338f
Define a base class for ProductFeedGeneratorService implementations a…
292881c
Resolve Typescript incompatible types error for feedGeneratorId
3e86bb7
Remove GoogleMerchantFeed Mapping defaults
74f758f
fix code format; add comments; add a general exception class.
umbracotrd e90f1c6
clean up codes
umbracotrd 4c0cfb0
remove unnecessary using statements
umbracotrd 4226ba7
bump version to 16.1.0
umbracotrd b82c698
Fix breaking changes
umbracotrd 8145676
Fix the breaking change
umbracotrd e75d1e3
enable package validation
umbracotrd 868a904
Fix breaking changes
umbracotrd 9a3e750
Split the ProductFeedController to make it easier to bump the api ver…
umbracotrd 946e385
rebuild frontend
umbracotrd 905d2b8
Fix a API breaking change
umbracotrd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Umbraco.Commerce.ProductFeeds.Core/Features/FeedGenerators/Application/FeedFormat.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Application | ||
{ | ||
public enum FeedFormat | ||
{ | ||
Unknown, | ||
Xml, | ||
Json | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
...rce.ProductFeeds.Core/Features/FeedGenerators/Application/IProductFeedGeneratorService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
using System.Text.Json; | ||
using System.Xml; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedSettings.Application; | ||
|
||
namespace Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Application | ||
{ | ||
public interface IProductFeedGeneratorService | ||
{ | ||
Task<XmlDocument> GenerateFeedAsync(ProductFeedSettingReadModel feedSetting); | ||
/// <summary> | ||
/// Returns the value extractor id. Must be unique. | ||
/// </summary> | ||
public string Id { get; } | ||
|
||
/// <summary> | ||
/// Returns a user friendly name of the value extractor. | ||
/// </summary> | ||
public string DisplayName { get; } | ||
|
||
/// <summary> | ||
/// Returns the feed format that this generator can generate. | ||
/// </summary> | ||
public FeedFormat Format { get; } | ||
Task<XmlDocument> GenerateXmlFeedAsync(ProductFeedSettingReadModel feedSetting) => throw new NotImplementedException(); | ||
umbracotrd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Task<JsonDocument> GenerateJsonFeedAsync(ProductFeedSettingReadModel feedSetting) => throw new NotImplementedException(); | ||
umbracotrd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...erce.ProductFeeds.Core/Features/FeedGenerators/Implementations/FeedGeneratorCollection.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Application; | ||
|
||
namespace Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Implementations | ||
{ | ||
public class FeedGeneratorCollection : BuilderCollectionBase<IProductFeedGeneratorService> | ||
{ | ||
public FeedGeneratorCollection(Func<IEnumerable<IProductFeedGeneratorService>> items) : base(items) | ||
{ | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...oductFeeds.Core/Features/FeedGenerators/Implementations/FeedGeneratorCollectionBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
umbracotrd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using Microsoft.Extensions.DependencyInjection; | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Application; | ||
|
||
namespace Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Implementations | ||
{ | ||
public class FeedGeneratorCollectionBuilder : OrderedCollectionBuilderBase<FeedGeneratorCollectionBuilder, FeedGeneratorCollection, IProductFeedGeneratorService> | ||
{ | ||
protected override FeedGeneratorCollectionBuilder This => this; | ||
protected override ServiceLifetime CollectionLifetime => ServiceLifetime.Scoped; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...rce.ProductFeeds.Core/Features/FeedGenerators/Implementations/FeedGeneratorServiceBase.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
umbracotrd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Application; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedSettings.Application; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.PropertyValueExtractors.Application; | ||
|
||
namespace Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Implementations | ||
{ | ||
public abstract class FeedGeneratorServiceBase : IProductFeedGeneratorService | ||
{ | ||
|
||
protected FeedGeneratorServiceBase( | ||
ISingleValuePropertyExtractorFactory singleValuePropertyExtractorFactory, | ||
IMultipleValuePropertyExtractorFactory multipleValuePropertyExtractorFactory) | ||
{ | ||
SingleValuePropertyExtractorFactory = singleValuePropertyExtractorFactory; | ||
MultipleValuePropertyExtractorFactory = multipleValuePropertyExtractorFactory; | ||
} | ||
|
||
public abstract string Id { get; } | ||
public abstract string DisplayName { get; } | ||
public abstract FeedFormat Format { get; } | ||
protected ISingleValuePropertyExtractorFactory SingleValuePropertyExtractorFactory { get; } | ||
protected IMultipleValuePropertyExtractorFactory MultipleValuePropertyExtractorFactory { get; } | ||
|
||
public virtual Task<XmlDocument> GenerateXmlFeedAsync(ProductFeedSettingReadModel feedSetting) | ||
{ | ||
throw new NotImplementedException("XML feed generation is not implemented."); | ||
} | ||
public virtual Task<JsonDocument> GenerateJsonFeedAsync(ProductFeedSettingReadModel feedSetting) | ||
{ | ||
throw new NotImplementedException("JSON feed generation is not implemented."); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 9 additions & 12 deletions
21
....ProductFeeds.Core/Features/FeedGenerators/Implementations/ProductFeedGeneratorFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Application; | ||
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedSettings.Application; | ||
|
||
namespace Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Implementations | ||
{ | ||
public class ProductFeedGeneratorFactory : IProductFeedGeneratorFactory | ||
{ | ||
private readonly IServiceProvider _serviceProvider; | ||
private readonly FeedGeneratorCollection _feedGenerators; | ||
|
||
public ProductFeedGeneratorFactory(IServiceProvider serviceProvider) | ||
public ProductFeedGeneratorFactory(FeedGeneratorCollection feedGenerators) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
_feedGenerators = feedGenerators; | ||
} | ||
|
||
public IProductFeedGeneratorService GetGenerator(ProductFeedType feedType) | ||
public IProductFeedGeneratorService GetGenerator(string feedGeneratorId) | ||
{ | ||
switch (feedType) | ||
{ | ||
case ProductFeedType.GoogleMerchantCenter: | ||
return _serviceProvider.GetRequiredService<GoogleMerchantCenterFeedService>(); | ||
IProductFeedGeneratorService? feedGenerator = _feedGenerators.FirstOrDefault(p => p.Id == feedGeneratorId); | ||
|
||
default: | ||
throw new InvalidOperationException($"Invalid feed type: {feedType}"); | ||
if (feedGenerator == null) | ||
{ | ||
throw new InvalidOperationException($"Invalid feed id: {feedGeneratorId}"); | ||
} | ||
|
||
return feedGenerator; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/Umbraco.Commerce.ProductFeeds.Core/Features/FeedSettings/Application/ProductFeedType.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.