Skip to content
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

Fix/363 dynamic values #367

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
961c626
prepare the concept of the dynamic model mapping with simple text
Feb 27, 2023
ee6a143
implement provider for IElements with just elements values (not the w…
Feb 28, 2023
7824c1f
rename the base calss for content items
Feb 28, 2023
75047ca
trial to wrap dynamic elements
Feb 28, 2023
cb405e0
fix the class vs. struct interoperability
Feb 28, 2023
2c6b5e9
inject another interface to base the element witout generic + more TODOs
Mar 6, 2023
fee4742
class per element value
Mar 6, 2023
876f83e
unify codename for content elements
Mar 6, 2023
aeab7fa
cleanup
Mar 6, 2023
aa257ea
extract to separate logic
Mar 28, 2023
58943b0
fix test
Mar 29, 2023
6f8d17a
add universal items async suport for listing + refactore tests
Mar 30, 2023
892644f
unify content items property types
Mar 30, 2023
6f11e78
trial no.3
Mar 30, 2023
bf91690
Revert "trial no.3"
Mar 30, 2023
f2305e7
implement delivery client cache + add happy path test
Mar 30, 2023
a08bd42
implement chache dependencies handling for universal items
Mar 31, 2023
2b20e65
prepare docs sceleton
Mar 31, 2023
3e63515
Add cache universal item by item key test
Mar 31, 2023
da3c083
Add linked items dependency test
Mar 31, 2023
fa1d8e0
add cache dependency invalidation exception for components
Mar 31, 2023
ebd3121
add test for max cache count
Mar 31, 2023
39d94d0
add test to combine both was of retrieving item with different cache key
Mar 31, 2023
f421dc6
add listing tests (and a few TODOs)
Apr 4, 2023
89b6e5c
format
Apr 4, 2023
000e168
get rid of TODOs vol.1
Apr 5, 2023
5a11940
get rid of TODOs vol.2
Apr 5, 2023
6c4c671
get rid of TODOs vol.3
Apr 5, 2023
e8aeddd
get rid of TODOs vol.4
Apr 5, 2023
602a406
cover deliveryClientBuilder with universalitemmodelprovider registrat…
Apr 5, 2023
afa8b97
prepare documentation
Apr 5, 2023
5d95e7d
Update universal-item-retrieval.md
Simply007 Apr 11, 2023
34bd2dc
Merge branch 'master' into fix/363-dynamic-values
Simply007 Apr 11, 2023
5787f66
adjust the method name
Apr 13, 2023
dce01c1
Rename IUniversalModelProvider.cs to IUniversalItemModelProvider.cs
Simply007 Apr 20, 2023
aacabd2
Merge branch 'master' into fix/363-dynamic-values
Simply007 May 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# INFO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
namespace Kontent.Ai.Delivery.Abstractions
{
/// <summary>
/// Represents a content element.
/// Represents a generic content element with value.
/// </summary>
public interface IContentElementValue<out T>
public interface IContentElementValue<out T> : IContentElementValue
{
/// <summary>
/// Gets the value of the content element.
/// </summary>
T Value { get; }
}

/// <summary>
/// Represents a content element.
/// </summary>
public interface IContentElementValue
{
/// <summary>
/// Gets the codename of the content element.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;

namespace Kontent.Ai.Delivery.Abstractions
{
public interface IDeliveryUniversalItemListingResponse : IResponse, IPageable
{
/// <summary>
/// Gets the content item.
/// </summary>
IList<IUniversalContentItem> Items { get; }


Dictionary<string, IUniversalContentItem> LinkedItems { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace Kontent.Ai.Delivery.Abstractions
{
/// <summary>
/// Represents a response from Kontent.ai Delivery API that contains a content item.
/// </summary>
public interface IDeliveryUniversalItemResponse: IDeliveryItemResponse<IUniversalContentItem>, IResponse
{
/// <summary>
/// Gets the content item.
/// </summary>
IUniversalContentItem Item { get; }

Dictionary<string, IUniversalContentItem> LinkedItems { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;

namespace Kontent.Ai.Delivery.Abstractions
{
/// <summary>
/// Dynamic representation of the content item dynamic item processing.
/// Values are based on <see cref="Kontent.Ai.Delivery.Abstractions.IContentElementValue{T}"/>
/// </summary>
public interface IUniversalContentItem : IContentItem
{
/// <summary>
/// Represents content items elements.
/// </summary>
public Dictionary<string, IContentElementValue> Elements { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Kontent.Ai.Delivery.Abstractions
{
/// <summary>
/// Interface ensuring mapping dynamic response to <see cref="IUniversalContentItem"/>.
/// </summary>
public interface IUniversalItemModelProvider
{
/// <summary>
/// Builds a model based on given JSON input.
/// </summary>
/// <param name="item">Content item data.</param>
/// <returns>Universal item</returns>
public Task<IUniversalContentItem> GetUniversalContentItemModelAsync(object item);
}
}
16 changes: 16 additions & 0 deletions Kontent.Ai.Delivery.Abstractions/IDeliveryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ public interface IDeliveryClient
/// <returns>The <see cref="IDeliveryItemResponse{T}"/> instance that contains the content item with the specified codename.</returns>
Task<IDeliveryItemResponse<T>> GetItemAsync<T>(string codename, IEnumerable<IQueryParameter> parameters = null);


/// <summary>
/// Returns item and its linked items in the <see cref="IUniversalContentItem"/> form.
/// </summary>
/// <param name="codename">The codename of a content item.</param>
/// <param name="parameters">A collection of query parameters, for example for projection or depth of linked items.</param>
/// <returns>The <see cref="IDeliveryUniversalItemResponse"/> instance that contains the content item and linked items with the specified codename.</returns>
Task<IDeliveryUniversalItemResponse> GetUniversalItemAsync(string codename, IEnumerable<IQueryParameter> parameters = null);

/// <summary>
/// Returns strongly typed content items that match the optional filtering parameters. By default, retrieves one level of linked items.
/// </summary>
Expand All @@ -25,6 +34,13 @@ public interface IDeliveryClient
/// <returns>The <see cref="IDeliveryItemListingResponse{T}"/> instance that contains the content items. If no query parameters are specified, all content items are returned.</returns>
Task<IDeliveryItemListingResponse<T>> GetItemsAsync<T>(IEnumerable<IQueryParameter> parameters = null);

/// <summary>
/// Returns <see cref="IUniversalContentItem"/> content items that match the optional filtering parameters. By default, retrieves one level of linked items.
/// </summary>
/// <param name="parameters">A collection of query parameters, for example, for filtering, ordering, or setting the depth of linked items.</param>
/// <returns>The <see cref="IDeliveryUniversalItemListingResponse" /> instance that contains the content items. If no query parameters are specified, all content items in the first page are returned.</returns>
Task<IDeliveryUniversalItemListingResponse> GetUniversalItemsAsync(IEnumerable<IQueryParameter> parameters = null);

/// <summary>
/// Returns a feed that is used to traverse through strongly typed content items matching the optional filtering parameters.
/// </summary>
Expand Down
Loading