-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust models to match sync API response for serialization
- Loading branch information
Showing
4 changed files
with
44 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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 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 System.Collections.Generic; | ||
|
||
namespace Kontent.Ai.Delivery.Abstractions; | ||
|
||
/// <summary> | ||
/// Represents a delta update. | ||
/// </summary> | ||
public interface ISyncItemData | ||
{ | ||
IContentItemSystemAttributes System { get; } | ||
object Elements { get; } | ||
} |
This file contains 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,45 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Kontent.Ai.Delivery.Abstractions; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Kontent.Ai.Delivery.Sync; | ||
|
||
/// <inheritdoc/> | ||
public class SyncItem : ISyncItem | ||
internal sealed class SyncItem : ISyncItem | ||
{ | ||
/// <inheritdoc/> | ||
[JsonProperty("codename")] | ||
public string Codename { get; internal set; } | ||
[JsonProperty("data")] | ||
public ISyncItemData Data { get; internal set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonProperty("id")] | ||
public Guid Id { get; internal set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonProperty("type")] | ||
public string Type { get; internal set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonProperty("language")] | ||
public string Language { get; internal set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonProperty("collection")] | ||
public string Collection { get; internal set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonProperty("change_type")] | ||
public string ChangeType { get; internal set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonProperty("timestamp")] | ||
public DateTime Timestamp { get; internal set; } | ||
|
||
/// <summary> | ||
/// Constructor used for deserialization (e.g. for caching purposes), contains no logic. | ||
/// </summary> | ||
[JsonConstructor] | ||
public SyncItem() | ||
{ | ||
public SyncItem(ISyncItemData data, string changeType, DateTime timestamp) { | ||
Data = data; | ||
ChangeType = changeType; | ||
Timestamp = timestamp; | ||
} | ||
} |
This file contains 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,22 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Kontent.Ai.Delivery.Abstractions; | ||
using Kontent.Ai.Delivery.ContentTypes.Element; | ||
using Newtonsoft.Json; | ||
|
||
namespace Kontent.Ai.Delivery.Sync | ||
{ | ||
public class SyncItemData : ISyncItemData | ||
{ | ||
[JsonProperty("system")] | ||
public IContentItemSystemAttributes System { get; internal set; } | ||
|
||
[JsonProperty("elements")] | ||
public object Elements { get; internal set; } | ||
|
||
[JsonConstructor] | ||
public SyncItemData() | ||
{ | ||
} | ||
} | ||
} |