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-376 Add contributors and note to language variants #279

Merged
merged 2 commits into from
Feb 5, 2025
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
50 changes: 30 additions & 20 deletions Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ public async void DeleteLanguageVariant()

await client.DeleteLanguageVariantAsync(identifier);
}

// DocSection: cm_api_v2_delete_legacy_webhook
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
[Fact]
public async void DeleteLegacyWebhook()
{
var client = _fileSystemFixture.CreateMockClient(Substitute.For<IManagementHttpClient>());

var identifier = Reference.ById(Guid.Parse("d53360f7-79e1-42f4-a524-1b53a417d03e"));

await client.DeleteLegacyWebhookAsync(identifier);
}

Expand Down Expand Up @@ -553,7 +553,7 @@ public async void GetVariantsWithComponentsOfType()

Assert.Single(response);
}

// DocSection: cm_api_v2_get_legacy_webhook
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
[Fact]
Expand All @@ -567,7 +567,7 @@ public async void GetLegacyWebhook()

Assert.NotNull(response);
}

// DocSection: cm_api_v2_get_webhook
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
[Fact]
Expand All @@ -593,7 +593,7 @@ public async void GetLegacyWebhooks()

Assert.Single(response);
}

// DocSection: cm_api_v2_get_webhooks
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
[Fact]
Expand Down Expand Up @@ -1442,7 +1442,7 @@ public async void PostLegacyWebhook()

Assert.NotNull(response);
}

// DocSection: cm_api_v2_post_webhook
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
[Fact]
Expand All @@ -1455,7 +1455,7 @@ public async void PostWebhook()
Name = "Example webhook",
Url = "https://example.com/webhook",
Secret = "secret_key",
Headers = new []
Headers = new[]
{
new CustomHeaderModel
{
Expand All @@ -1473,22 +1473,23 @@ public async void PostWebhook()
ContentType = new ContentTypeTriggerModel
{
Enabled = true,
Actions = new []
Actions = new[]
{
new ContentTypeActionModel { Action = ContentTypeAction.Created },
new ContentTypeActionModel { Action = ContentTypeAction.Changed },
new ContentTypeActionModel { Action = ContentTypeAction.Deleted }
},
Filters = new ContentTypeFiltersModel {
ContentTypes = new [] {
Filters = new ContentTypeFiltersModel
{
ContentTypes = new[] {
Reference.ById(Guid.Parse("dd1439d5-4ee2-4895-a4e4-5b0d9d8c754e"))
}
}
},
ContentItem = new ContentItemTriggerModel
{
Enabled = true,
Actions = new []
Actions = new[]
{
new ContentItemActionModel
{
Expand All @@ -1504,7 +1505,7 @@ public async void PostWebhook()
},
Filters = new ContentItemFiltersModel
{
Languages = new []
Languages = new[]
{
Reference.ById(Guid.Parse("1aeb9220-f167-4f8e-a7db-1bfec365fa80"))
}
Expand All @@ -1513,7 +1514,7 @@ public async void PostWebhook()
Taxonomy = new TaxonomyTriggerModel
{
Enabled = true,
Actions = new []
Actions = new[]
{
new TaxonomyActionModel { Action = TaxonomyAction.TermChanged },
new TaxonomyActionModel { Action = TaxonomyAction.MetadataChanged }
Expand All @@ -1528,7 +1529,7 @@ public async void PostWebhook()
Asset = new AssetTriggerModel
{
Enabled = true,
Actions = new []
Actions = new[]
{
new AssetActionModel { Action = AssetAction.Created },
new AssetActionModel { Action = AssetAction.Changed }
Expand All @@ -1537,7 +1538,7 @@ public async void PostWebhook()
Language = new LanguageTriggerModel
{
Enabled = true,
Actions = new []
Actions = new[]
{
new LanguageActionModel { Action = LanguageAction.Created }
},
Expand Down Expand Up @@ -1666,7 +1667,8 @@ public async void PostCloneEnvironment()
{
Guid.Parse("2f925111-1457-49d4-a595-0958feae8ae4")
},
CopyDataOptions = new CopyDataOptions {
CopyDataOptions = new CopyDataOptions
{
ContentItemsAssets = true,
ContentItemVersionHistory = false
}
Expand Down Expand Up @@ -2025,7 +2027,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> { UserIdentifier.ByEmail("[email protected]") },
Note = "Moving this to the next workflow step."
}
));
Assert.Null(exception);
}
Expand All @@ -2041,7 +2051,7 @@ public async void PutDisableLegacyWebhook()
await client.DisableLegacyWebhookAsync(Reference.ById(Guid.Parse("5df74e27-1213-484e-b9ae-bcbe90bd5990"))));
Assert.Null(exception);
}

// DocSection: mapi_v2_disable_webhook
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
[Fact]
Expand All @@ -2065,7 +2075,7 @@ public async void PutEnableLegacyWebhook()
await client.EnableLegacyWebhookAsync(Reference.ById(Guid.Parse("5df74e27-1213-484e-b9ae-bcbe90bd5990"))));
Assert.Null(exception);
}

// DocSection: mapi_v2_enable_webhook
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};

Expand All @@ -544,6 +546,8 @@ private static LanguageVariantModel<ComplexTestModel> 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(),
};

Expand All @@ -558,6 +562,9 @@ private static LanguageVariantModel<ComplexTestModel> GetExpectedComplexTestMode
private static DueDateModel GetExpectedDueDateModel() =>
new() { Value = DateTimeOffset.Parse("2092-01-07T06:04:00.7069564Z").UtcDateTime };

private static List<UserIdentifier> GetExpectedContributors() =>
new List<UserIdentifier>() { UserIdentifier.ById("4b628214-e4fe-4fe0-b1ff-955df33e1515") };

private class CombinationOfIdentifiersAndUrl : IEnumerable<object[]>
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -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<ArgumentNullException>();
await client.Invoking(x => x.ChangeLanguageVariantWorkflowAsync(null, model)).Should().ThrowAsync<ArgumentNullException>();
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions Kontent.Ai.Management/IManagementClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ public interface IManagementClient
/// Changes workflow.
/// </summary>
/// <param name="identifier">Identifier of the language variant to be changed.</param>
/// <param name="workflowStepIdentifier">Workflow step identifier to set.</param>
Task ChangeLanguageVariantWorkflowAsync(LanguageVariantIdentifier identifier, WorkflowStepIdentifier workflowStepIdentifier);
/// <param name="changeModel">Change language variant workflow model.</param>
Task ChangeLanguageVariantWorkflowAsync(LanguageVariantIdentifier identifier, ChangeLanguageVariantWorkflowModel changeModel);

/// <summary>
/// Creates the asset folder.
Expand Down
Loading