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

EN-125 Add due date to content item variant #262

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,11 @@ public async void PutLanguageVariant()
Element = Reference.ByCodename("url_pattern"),
Mode = "autogenerated"
},
})
}),
DueDate = new DueDateModel
{
Value = DateTime.Parse("2092-01-07T06:04:00.7069564Z")
}
},
new WorkflowStepIdentifier(Reference.ByCodename("default"), Reference.ByCodename("review")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "4b628214-e4fe-4fe0-b1ff-955df33e1515"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "4b628214-e4fe-4fe0-b1ff-955df33e1515"
},
Expand Down Expand Up @@ -357,6 +360,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "4b628214-e4fe-4fe0-b1ff-955df33e1515"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "00000000-0000-0000-0000-000000000000"
},
Expand Down Expand Up @@ -358,6 +361,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "00000000-0000-0000-0000-000000000000"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "10000000-0000-0000-0000-000000000000"
},
Expand Down Expand Up @@ -358,6 +361,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "10000000-0000-0000-0000-000000000000"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "20000000-0000-0000-0000-000000000000"
},
Expand Down Expand Up @@ -354,10 +357,16 @@
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"step_identifier": {
"id": "eee6db3b-545a-4785-8e86-e3772c8756f9"
}
},
"due_date": {
"value": "2092-01-07T06:04:00.7069564Z"
},
"item": {
"id": "20000000-0000-0000-0000-000000000000"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ private static LanguageVariantModel GetExpectedLanguageVariantModel(
LastModified = DateTimeOffset.Parse("2021-11-06T13:57:26.7069564Z").UtcDateTime,
Workflow = new WorkflowStepIdentifier(Reference.ById(Guid.Parse("00000000-0000-0000-0000-000000000000")), Reference.ById(Guid.Parse("eee6db3b-545a-4785-8e86-e3772c8756f9"))),
Schedule = GetExpectedScheduleResponseModel(),
DueDate = GetExpectedDueDateModel(),
Elements = ElementsData.GetExpectedDynamicElements(),
};

Expand All @@ -450,6 +451,7 @@ private static List<LanguageVariantModel<ComplexTestModel>> GetExpectedComplexTe
LastModified = DateTimeOffset.Parse("2021-11-06T13:57:26.7069564Z").UtcDateTime,
Workflow = new WorkflowStepIdentifier(Reference.ById(Guid.Parse("00000000-0000-0000-0000-000000000000")), Reference.ById(Guid.Parse("eee6db3b-545a-4785-8e86-e3772c8756f9"))),
Schedule = GetExpectedScheduleResponseModel(),
DueDate = GetExpectedDueDateModel(),
Elements = ElementsData.GetExpectedStronglyTypedElementsModel(),
};

Expand All @@ -461,6 +463,9 @@ private static List<LanguageVariantModel<ComplexTestModel>> GetExpectedComplexTe
UnpublishDisplayTimeZone = "Europe/Prague"
};

private static DueDateModel GetExpectedDueDateModel() =>
new() { Value = DateTimeOffset.Parse("2092-01-07T06:04:00.7069564Z").UtcDateTime };

private class CombinationOfIdentifiersAndUrl : IEnumerable<object[]>
{

Expand Down
16 changes: 16 additions & 0 deletions Kontent.Ai.Management/Models/LanguageVariants/DueDateModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;
using System;

namespace Kontent.Ai.Management.Models.LanguageVariants;

/// <summary>
/// Represents due date model.
/// </summary>
public class DueDateModel
{
/// <summary>
/// Gets or sets ISO-8601 formatted date-time for due date.
/// </summary>
[JsonProperty("value")]
public DateTime? Value { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ public sealed class LanguageVariantModel
/// </summary>
[JsonProperty("workflow")]
public WorkflowStepIdentifier Workflow { get; set; }

/// <summary>
/// Gets or sets due date.
/// </summary>
[JsonProperty("due_date")]
public DueDateModel DueDate { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public sealed class LanguageVariantUpsertModel
/// </summary>
public WorkflowStepIdentifier Workflow { get; set; }

/// <summary>
/// Gets or sets due date to update.
/// </summary>
public DueDateModel DueDate { get; set; }

/// <summary>
/// Creates an instance of the language variant upsert model.
/// </summary>
Expand All @@ -31,5 +36,6 @@ internal LanguageVariantUpsertModel(LanguageVariantModel languageVariant)
{
Elements = languageVariant.Elements;
Workflow = languageVariant.Workflow;
DueDate = languageVariant.DueDate;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Kontent.Ai.Management.Models.Publishing;
using Kontent.Ai.Management.Models.LanguageVariants;
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.Workflow;
using Newtonsoft.Json;
Expand Down Expand Up @@ -46,4 +47,10 @@ namespace Kontent.Ai.Management.Models.StronglyTyped;
/// </summary>
[JsonProperty("workflow")]
public WorkflowStepIdentifier Workflow { get; set; }

/// <summary>
/// Gets or sets due date.
/// </summary>
[JsonProperty("due_date")]
public DueDateModel DueDate { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ internal ModelProvider()
LastModified = variant.LastModified,
Schedule = variant.Schedule,
Workflow = variant.Workflow,
Elements = _elementModelProvider.GetStronglyTypedElements<T>(variant.Elements)
DueDate = variant.DueDate,
Elements = _elementModelProvider.GetStronglyTypedElements<T>(variant.Elements),
};

public LanguageVariantUpsertModel GetLanguageVariantUpsertModel<T>(T variantElements, WorkflowStepIdentifier workflow = null) where T : new() =>
Expand Down
Loading