Skip to content

Commit

Permalink
EN-130 - Add schedules to content item variant
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirO-kontent committed Apr 2, 2024
1 parent 24e60b5 commit 1110bce
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ public async void PutPublishLanguageVariant()
// Scheduled publish
var scheduledPublishException = await Record.ExceptionAsync(async () => await client.SchedulePublishingOfLanguageVariantAsync(identifier, new ScheduleModel
{
ScheduleTo = DateTime.Parse("2038-01-19T04:14:08+01:00"),
ScheduleTo = DateTime.Parse("2038-01-19T04:14:08"),
DisplayTimeZone = "Europe/London"
}));

Expand Down Expand Up @@ -1946,7 +1946,7 @@ public async void PutUnpublishLanguageVariant()
// Scheduled unpublish
var scheduledUnpublishException = await Record.ExceptionAsync(async () => await client.ScheduleUnpublishingOfLanguageVariantAsync(identifier, new ScheduleModel
{
ScheduleTo = DateTime.Parse("2038-01-19T04:14:08+01:00"),
ScheduleTo = DateTime.Parse("2038-01-19T04:14:08"),
DisplayTimeZone = "Europe/London"
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -337,6 +343,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -338,6 +344,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -338,6 +344,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -338,6 +344,12 @@
]
}
],
"schedule": {
"publish_time": "2024-03-31T08:00:00",
"publish_display_timezone": "Europe/Prague",
"unpublish_time": "2024-04-30T08:00:00",
"unpublish_display_timezone": "Europe/Prague"
},
"workflow": {
"workflow_identifier": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FluentAssertions;
using Kontent.Ai.Management.Extensions;
using Kontent.Ai.Management.Models.LanguageVariants;
using Kontent.Ai.Management.Models.Publishing;
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.StronglyTyped;
using Kontent.Ai.Management.Models.Workflow;
Expand Down Expand Up @@ -435,6 +436,7 @@ private static LanguageVariantModel GetExpectedLanguageVariantModel(
Language = Reference.ById(Guid.Parse(languageId)),
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(),
Elements = ElementsData.GetExpectedDynamicElements(),
};

Expand All @@ -447,9 +449,18 @@ private static List<LanguageVariantModel<ComplexTestModel>> GetExpectedComplexTe
Language = Reference.ById(Guid.Parse(languageId)),
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(),
Elements = ElementsData.GetExpectedStronglyTypedElementsModel(),
};

private static ScheduleResponseModel GetExpectedScheduleResponseModel() => new()
{
PublishTime = DateTimeOffset.Parse("2024-03-31T08:00:00").UtcDateTime,
PublishDisplayTimeZone = "Europe/Prague",
UnpublishTime = DateTimeOffset.Parse("2024-04-30T08:00:00").UtcDateTime,
UnpublishDisplayTimeZone = "Europe/Prague"
};

private class CombinationOfIdentifiersAndUrl : IEnumerable<object[]>
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.Publishing;
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.Workflow;
using Newtonsoft.Json;
using System;
Expand Down Expand Up @@ -35,6 +36,12 @@ public sealed class LanguageVariantModel
[JsonProperty("last_modified")]
public DateTime? LastModified { get; set; }

/// <summary>
/// Gets or sets the publishing and unpublishing schedule of the language variant.
/// </summary>
[JsonProperty("schedule")]
public ScheduleResponseModel Schedule { get; set; }

/// <summary>
/// Gets or sets workflow step identifier.
/// </summary>
Expand Down
34 changes: 34 additions & 0 deletions Kontent.Ai.Management/Models/Publishing/ScheduleResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Newtonsoft.Json;
using System;

namespace Kontent.Ai.Management.Models.Publishing;

/// <summary>
/// Represents the schedule model.
/// </summary>
public class ScheduleResponseModel
{
/// <summary>
/// Gets or sets ISO-8601 formatted date-time for scheduled publishing.
/// </summary>
[JsonProperty("publish_time")]
public DateTime? PublishTime { get; set; }

/// <summary>
/// IANA time zone name used to display time offset of the scheduled publish date in the UI.
/// </summary>
[JsonProperty("publish_display_timezone")]
public string PublishDisplayTimeZone { get; set; }

/// <summary>
/// Gets or sets ISO-8601 formatted date-time for scheduled unpublishing.
/// </summary>
[JsonProperty("unpublish_time")]
public DateTime? UnpublishTime { get; set; }

/// <summary>
/// IANA time zone name used to display time offset of the scheduled unpublish date in the UI.
/// </summary>
[JsonProperty("unpublish_display_timezone")]
public string UnpublishDisplayTimeZone { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.Publishing;
using Kontent.Ai.Management.Models.Shared;
using Kontent.Ai.Management.Models.Workflow;
using Newtonsoft.Json;
using System;
Expand Down Expand Up @@ -34,6 +35,12 @@ namespace Kontent.Ai.Management.Models.StronglyTyped;
[JsonProperty("last_modified")]
public DateTime? LastModified { get; set; }

/// <summary>
/// Gets or sets the publishing and unpublishing schedule of the language variant.
/// </summary>
[JsonProperty("schedule")]
public ScheduleResponseModel Schedule { get; set; }

/// <summary>
/// Gets or sets workflow step identifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal ModelProvider()
Item = variant.Item,
Language = variant.Language,
LastModified = variant.LastModified,
Schedule = variant.Schedule,
Workflow = variant.Workflow,
Elements = _elementModelProvider.GetStronglyTypedElements<T>(variant.Elements)
};
Expand Down

0 comments on commit 1110bce

Please sign in to comment.