diff --git a/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs b/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs index 22c8d81b..2e754530 100644 --- a/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs +++ b/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs @@ -2025,7 +2025,15 @@ public async void PutVariantWorkflow() var exception = await Record.ExceptionAsync(async () => await client.ChangeLanguageVariantWorkflowAsync( new LanguageVariantIdentifier(itemIdentifier, languageIdentifier), - new WorkflowStepIdentifier(Reference.ById(Guid.Empty), workflowStepIdentifier) + new ChangeLanguageVariantWorkflowModel(Reference.ById(Guid.Empty), workflowStepIdentifier) + { + DueDate = new DueDateModel + { + Value = DateTime.UtcNow.AddDays(42) + }, + Contributors = new List { UserIdentifier.ByEmail("user@kontent.ai") }, + Note = "Moving this to the next workflow step." + } )); Assert.Null(exception); } diff --git a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariant.json b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariant.json index 437d1cb4..b0f3575a 100644 --- a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariant.json +++ b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariant.json @@ -176,6 +176,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" }, diff --git a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariants.json b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariants.json index c0d816f8..cc01016a 100644 --- a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariants.json +++ b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariants.json @@ -177,6 +177,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" }, @@ -363,6 +369,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" }, diff --git a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage1.json b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage1.json index faa8e867..9b19420d 100644 --- a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage1.json +++ b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage1.json @@ -178,6 +178,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "00000000-0000-0000-0000-000000000000" }, @@ -364,6 +370,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "00000000-0000-0000-0000-000000000000" }, diff --git a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage2.json b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage2.json index 9f87ed35..397d2ed8 100644 --- a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage2.json +++ b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage2.json @@ -178,6 +178,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "10000000-0000-0000-0000-000000000000" }, @@ -364,6 +370,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "10000000-0000-0000-0000-000000000000" }, diff --git a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage3.json b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage3.json index d1ba36db..ca5f6808 100644 --- a/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage3.json +++ b/Kontent.Ai.Management.Tests/Data/LanguageVariant/LanguageVariantsPage3.json @@ -178,6 +178,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "20000000-0000-0000-0000-000000000000" }, @@ -367,6 +373,12 @@ "due_date": { "value": "2092-01-07T06:04:00.7069564Z" }, + "contributors": [ + { + "id": "4b628214-e4fe-4fe0-b1ff-955df33e1515" + } + ], + "note": "Just a note", "item": { "id": "20000000-0000-0000-0000-000000000000" }, diff --git a/Kontent.Ai.Management.Tests/ManagementClientTests/LanguageVariantTests.cs b/Kontent.Ai.Management.Tests/ManagementClientTests/LanguageVariantTests.cs index 9eaa30dd..7a67774d 100644 --- a/Kontent.Ai.Management.Tests/ManagementClientTests/LanguageVariantTests.cs +++ b/Kontent.Ai.Management.Tests/ManagementClientTests/LanguageVariantTests.cs @@ -528,6 +528,8 @@ private static LanguageVariantModel GetExpectedLanguageVariantModel( 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(), + Contributors = GetExpectedContributors(), + Note = "Just a note", Elements = ElementsData.GetExpectedDynamicElements(), }; @@ -544,6 +546,8 @@ private static LanguageVariantModel GetExpectedComplexTestMode 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(), + Contributors = GetExpectedContributors(), + Note = "Just a note", Elements = ElementsData.GetExpectedStronglyTypedElementsModel(), }; @@ -558,6 +562,9 @@ private static LanguageVariantModel GetExpectedComplexTestMode private static DueDateModel GetExpectedDueDateModel() => new() { Value = DateTimeOffset.Parse("2092-01-07T06:04:00.7069564Z").UtcDateTime }; + private static List GetExpectedContributors() => + new List() { UserIdentifier.ById("4b628214-e4fe-4fe0-b1ff-955df33e1515") }; + private class CombinationOfIdentifiersAndUrl : IEnumerable { diff --git a/Kontent.Ai.Management.Tests/ManagementClientTests/PublishingTests.cs b/Kontent.Ai.Management.Tests/ManagementClientTests/PublishingTests.cs index e7f9500e..a21f0558 100644 --- a/Kontent.Ai.Management.Tests/ManagementClientTests/PublishingTests.cs +++ b/Kontent.Ai.Management.Tests/ManagementClientTests/PublishingTests.cs @@ -2,7 +2,6 @@ using Kontent.Ai.Management.Models.LanguageVariants; using Kontent.Ai.Management.Models.Publishing; using Kontent.Ai.Management.Models.Shared; -using Kontent.Ai.Management.Models.Workflow; using Kontent.Ai.Management.Tests.Base; using System; using System.Collections; @@ -28,18 +27,18 @@ public async void ChangeLanguageVariantWorkflowAsync_ChangesWorkflow(LanguageVar { var client = _scenario.CreateManagementClient(); - var workflowIdentifier = new WorkflowStepIdentifier + var model = new ChangeLanguageVariantWorkflowModel ( workflowIdentifier: Reference.ById(Guid.NewGuid()), stepIdentifier: Reference.ById(Guid.NewGuid()) ); - await client.ChangeLanguageVariantWorkflowAsync(variantIdentifier, workflowIdentifier); + await client.ChangeLanguageVariantWorkflowAsync(variantIdentifier, model); _scenario .CreateExpectations() .HttpMethod(HttpMethod.Put) - .RequestPayload(workflowIdentifier) + .RequestPayload(model) .Url($"{expectedUrl}/change-workflow") .Validate(); } @@ -49,13 +48,13 @@ public async void ChangeLanguageVariantWorkflowAsync_NoIdentifier_Throws() { var client = _scenario.CreateManagementClient(); - var workflowIdentifier = new WorkflowStepIdentifier + var model = new ChangeLanguageVariantWorkflowModel ( workflowIdentifier: Reference.ById(Guid.NewGuid()), stepIdentifier: Reference.ById(Guid.NewGuid()) ); - await client.Invoking(x => x.ChangeLanguageVariantWorkflowAsync(null, workflowIdentifier)).Should().ThrowAsync(); + await client.Invoking(x => x.ChangeLanguageVariantWorkflowAsync(null, model)).Should().ThrowAsync(); } [Fact] diff --git a/Kontent.Ai.Management/IManagementClient.cs b/Kontent.Ai.Management/IManagementClient.cs index e45fe36a..3961954f 100644 --- a/Kontent.Ai.Management/IManagementClient.cs +++ b/Kontent.Ai.Management/IManagementClient.cs @@ -164,8 +164,8 @@ public interface IManagementClient /// Changes workflow. /// /// Identifier of the language variant to be changed. - /// Workflow step identifier to set. - Task ChangeLanguageVariantWorkflowAsync(LanguageVariantIdentifier identifier, WorkflowStepIdentifier workflowStepIdentifier); + /// Change language variant workflow model. + Task ChangeLanguageVariantWorkflowAsync(LanguageVariantIdentifier identifier, ChangeLanguageVariantWorkflowModel changeModel); /// /// Creates the asset folder. diff --git a/Kontent.Ai.Management/ManagementClient.Publishing.cs b/Kontent.Ai.Management/ManagementClient.Publishing.cs index c97590dc..be5c43ab 100644 --- a/Kontent.Ai.Management/ManagementClient.Publishing.cs +++ b/Kontent.Ai.Management/ManagementClient.Publishing.cs @@ -1,6 +1,5 @@ using Kontent.Ai.Management.Models.LanguageVariants; using Kontent.Ai.Management.Models.Publishing; -using Kontent.Ai.Management.Models.Workflow; using System; using System.Net.Http; using System.Threading.Tasks; @@ -13,15 +12,15 @@ namespace Kontent.Ai.Management; public sealed partial class ManagementClient { /// - public async Task ChangeLanguageVariantWorkflowAsync(LanguageVariantIdentifier identifier, WorkflowStepIdentifier workflowStepIdentifier) + public async Task ChangeLanguageVariantWorkflowAsync(LanguageVariantIdentifier identifier, ChangeLanguageVariantWorkflowModel changeModel) { ArgumentNullException.ThrowIfNull(identifier); - ArgumentNullException.ThrowIfNull(workflowStepIdentifier); + ArgumentNullException.ThrowIfNull(changeModel); var endpointUrl = _urlBuilder.BuildWorkflowChangeUrl(identifier); - await _actionInvoker.InvokeMethodAsync(endpointUrl, HttpMethod.Put, workflowStepIdentifier); + await _actionInvoker.InvokeMethodAsync(endpointUrl, HttpMethod.Put, changeModel); } /// diff --git a/Kontent.Ai.Management/Models/LanguageVariants/ChangeLanguageVariantWorkflowModel.cs b/Kontent.Ai.Management/Models/LanguageVariants/ChangeLanguageVariantWorkflowModel.cs new file mode 100644 index 00000000..7a451062 --- /dev/null +++ b/Kontent.Ai.Management/Models/LanguageVariants/ChangeLanguageVariantWorkflowModel.cs @@ -0,0 +1,52 @@ +using Kontent.Ai.Management.Models.Shared; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace Kontent.Ai.Management.Models.LanguageVariants; + +/// +/// Represents a change language variant workflow model. +/// +public sealed class ChangeLanguageVariantWorkflowModel +{ + /// + /// Represents the identifier of the workflow. + /// + [JsonProperty("workflow_identifier")] + public Reference Workflow { get; set; } + + /// + /// Represents the identifier of the step in the workflow. + /// + [JsonProperty("step_identifier")] + public Reference Step { get; set; } + + /// + /// Gets or sets due date. + /// + [JsonProperty("due_date")] + public DueDateModel DueDate { get; set; } + + /// + /// Gets or sets a note. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// Gets or sets the contributors. + /// + [JsonProperty("contributors")] + public IEnumerable Contributors { get; set; } + + /// + /// Creates an instance of the change language variant workflow model. + /// + /// The identifier of the workflow. + /// The identifier of the workflow step. + public ChangeLanguageVariantWorkflowModel(Reference workflowIdentifier, Reference stepIdentifier) + { + Workflow = workflowIdentifier; + Step = stepIdentifier; + } +} diff --git a/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantModel.cs b/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantModel.cs index 8b7ecf64..b1086023 100644 --- a/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantModel.cs +++ b/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantModel.cs @@ -53,4 +53,16 @@ public sealed class LanguageVariantModel /// [JsonProperty("due_date")] public DueDateModel DueDate { get; set; } + + /// + /// Gets or sets a note. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// Gets or sets the contributors. + /// + [JsonProperty("contributors")] + public IEnumerable Contributors { get; set; } } diff --git a/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantUpsertModel.cs b/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantUpsertModel.cs index 96827422..edec2d65 100644 --- a/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantUpsertModel.cs +++ b/Kontent.Ai.Management/Models/LanguageVariants/LanguageVariantUpsertModel.cs @@ -1,4 +1,5 @@ -using Kontent.Ai.Management.Models.Workflow; +using Kontent.Ai.Management.Models.Shared; +using Kontent.Ai.Management.Models.Workflow; using Newtonsoft.Json; using System.Collections.Generic; @@ -25,6 +26,18 @@ public sealed class LanguageVariantUpsertModel /// public DueDateModel DueDate { get; set; } + /// + /// Gets or sets a note. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// Gets or sets the contributors. + /// + [JsonProperty("contributors")] + public IEnumerable Contributors { get; set; } + /// /// Creates an instance of the language variant upsert model. /// @@ -37,5 +50,7 @@ internal LanguageVariantUpsertModel(LanguageVariantModel languageVariant) Elements = languageVariant.Elements; Workflow = languageVariant.Workflow; DueDate = languageVariant.DueDate; + Note = languageVariant.Note; + Contributors = languageVariant.Contributors; } } diff --git a/Kontent.Ai.Management/Models/Shared/UserIdentifier.cs b/Kontent.Ai.Management/Models/Shared/UserIdentifier.cs index cd3a4bf5..c25938f4 100644 --- a/Kontent.Ai.Management/Models/Shared/UserIdentifier.cs +++ b/Kontent.Ai.Management/Models/Shared/UserIdentifier.cs @@ -1,4 +1,6 @@ -namespace Kontent.Ai.Management.Models.Shared; +using Newtonsoft.Json; + +namespace Kontent.Ai.Management.Models.Shared; /// /// Represents identifier of users. @@ -10,11 +12,13 @@ private UserIdentifier() { } /// /// Gets the id of the identifier. /// + [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] public string Id { get; private set; } /// /// Gets the email of the identifier. /// + [JsonProperty("email", DefaultValueHandling = DefaultValueHandling.Ignore)] public string Email { get; private set; } /// diff --git a/Kontent.Ai.Management/Models/StronglyTyped/LanguageVariantModel.cs b/Kontent.Ai.Management/Models/StronglyTyped/LanguageVariantModel.cs index f0da61af..8d100f4f 100644 --- a/Kontent.Ai.Management/Models/StronglyTyped/LanguageVariantModel.cs +++ b/Kontent.Ai.Management/Models/StronglyTyped/LanguageVariantModel.cs @@ -4,6 +4,7 @@ using Kontent.Ai.Management.Models.Workflow; using Newtonsoft.Json; using System; +using System.Collections.Generic; namespace Kontent.Ai.Management.Models.StronglyTyped; @@ -53,4 +54,16 @@ namespace Kontent.Ai.Management.Models.StronglyTyped; /// [JsonProperty("due_date")] public DueDateModel DueDate { get; set; } + + /// + /// Gets or sets a note. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// Gets or sets the contributors. + /// + [JsonProperty("contributors")] + public IEnumerable Contributors { get; set; } } diff --git a/Kontent.Ai.Management/Modules/ModelBuilders/ModelProvider.cs b/Kontent.Ai.Management/Modules/ModelBuilders/ModelProvider.cs index 755af490..9a58fba6 100644 --- a/Kontent.Ai.Management/Modules/ModelBuilders/ModelProvider.cs +++ b/Kontent.Ai.Management/Modules/ModelBuilders/ModelProvider.cs @@ -23,6 +23,8 @@ internal ModelProvider() Schedule = variant.Schedule, Workflow = variant.Workflow, DueDate = variant.DueDate, + Note = variant.Note, + Contributors = variant.Contributors, Elements = _elementModelProvider.GetStronglyTypedElements(variant.Elements), };