Skip to content
Open
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [v1.0.0-beta.6](https://github.com/contentstack/contentstack-management-dotnet/tree/v1.0.0-beta.6)
- **Entry, Entry Variant & Variant Group STJ Migration Complete**
- Migrated Entry and EntryVariant modules from Newtonsoft.Json to System.Text.Json
- Fully migrated VariantGroup module with VariantContentTypeLinkService using Utf8JsonWriter
- Re-enabled Stack.VariantGroup() method for variant group operations
- Updated service constructors to use JsonSerializerOptions instead of JsonSerializer
- Enhanced variant group API integration with proper content type linking
- Removed build exclusions for VariantGroup files to re-enable module functionality

## [v1.0.0-beta.5](https://github.com/contentstack/contentstack-management-dotnet/tree/v1.0.0-beta.5)
- **Environment & Global Field STJ Migration**
- Migrated Environment and Global Field modules from Newtonsoft.Json to System.Text.Json
Expand Down
5 changes: 2 additions & 3 deletions Contentstack.Management.Core/Abstractions/IEntry.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace Contentstack.Management.Core.Abstractions
{
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public interface IEntry
{
[JsonProperty(propertyName: "title")]
[JsonPropertyName("title")]
string Title { get; set; }
}
}
2 changes: 0 additions & 2 deletions Contentstack.Management.Core/Models/ContentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public override Task<ContentstackResponse> DeleteAsync(ParameterCollection? coll
return base.DeleteAsync(collection);
}

/*
/// <summary>
/// <see cref="Models.Entry" /> is the actual piece of content created using one of the defined content types.
/// </summary>
Expand All @@ -177,6 +176,5 @@ public Entry Entry(string uid = null)
ThrowIfUidEmpty();
return new Entry(stack, Uid, uid);
}
*/
}
}
58 changes: 27 additions & 31 deletions Contentstack.Management.Core/Models/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Text.Json;
using Contentstack.Management.Core.Abstractions;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -211,10 +210,10 @@ public ContentstackResponse DeleteMultipleLocal(List<string> locales)
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new DeleteService<Dictionary<string, List<string>>>(stack.client.serializer, stack, resourcePath, "entry", new Dictionary<string, List<string>>()
var service = new DeleteService<Dictionary<string, List<string>>>(stack, resourcePath, "entry", new Dictionary<string, List<string>>()
{
{"locales", locales }
});
}, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeSync(service);
}

Expand All @@ -235,10 +234,10 @@ public Task<ContentstackResponse> DeleteMultipleLocalAsync(List<string> locales)
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new DeleteService<Dictionary<string, List<string>>>(stack.client.serializer, stack, resourcePath, "entry", new Dictionary<string, List<string>>()
var service = new DeleteService<Dictionary<string, List<string>>>(stack, resourcePath, "entry", new Dictionary<string, List<string>>()
{
{"locales", locales }
});
}, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeAsync<DeleteService<Dictionary<string, List<string>>>, ContentstackResponse>(service);
}

Expand All @@ -264,7 +263,7 @@ public ContentstackResponse Localize(IEntry model, string locale)

collection.Add("locale", locale);

var service = new LocalizationService<IEntry>(stack.client.serializer, stack, resourcePath, model, "entry", collection);
var service = new LocalizationService<IEntry>(stack.client.SerializerOptions, stack, resourcePath, model, "entry", collection);
return stack.client.InvokeSync(service);
}

Expand All @@ -290,7 +289,7 @@ public Task<ContentstackResponse> LocalizeAsync(IEntry model, string locale)

collection.Add("locale", locale);

var service = new LocalizationService<IEntry>(stack.client.serializer, stack, resourcePath, model, "entry", collection);
var service = new LocalizationService<IEntry>(stack.client.SerializerOptions, stack, resourcePath, model, "entry", collection);
return stack.client.InvokeAsync<LocalizationService<IEntry>, ContentstackResponse>(service);
}

Expand All @@ -314,7 +313,7 @@ public ContentstackResponse Unlocalize(string locale)

collection.Add("locale", locale);

var service = new LocalizationService<IEntry>(stack.client.serializer, stack, resourcePath, null, "entry", collection, true);
var service = new LocalizationService<IEntry>(stack.client.SerializerOptions, stack, resourcePath, null, "entry", collection, true);
return stack.client.InvokeSync(service);
}

Expand All @@ -338,7 +337,7 @@ public Task<ContentstackResponse> UnlocalizeAsync(string locale)

collection.Add("locale", locale);

var service = new LocalizationService<IEntry>(stack.client.serializer, stack, resourcePath, null, "entry", collection, true);
var service = new LocalizationService<IEntry>(stack.client.SerializerOptions, stack, resourcePath, null, "entry", collection, true);
return stack.client.InvokeAsync<LocalizationService<IEntry>, ContentstackResponse>(service);
}

Expand All @@ -357,7 +356,7 @@ public ContentstackResponse Locales()
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new LocaleService(stack.client.serializer, stack, resourcePath);
var service = new LocaleService(stack.client.SerializerOptions, stack, resourcePath);
return stack.client.InvokeSync(service);
}

Expand All @@ -376,7 +375,7 @@ public Task<ContentstackResponse> LocalesAsync()
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new LocaleService(stack.client.serializer, stack, resourcePath);
var service = new LocaleService(stack.client.SerializerOptions, stack, resourcePath);
return stack.client.InvokeAsync<LocaleService, ContentstackResponse>(service);
}

Expand All @@ -395,7 +394,7 @@ public ContentstackResponse References(ParameterCollection collection = null)
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new FetchReferencesService(stack.client.serializer, stack, resourcePath, collection: collection);
var service = new FetchReferencesService(stack, resourcePath, collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeSync(service);
}

Expand All @@ -414,7 +413,7 @@ public Task<ContentstackResponse> ReferencesAsync(ParameterCollection collection
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new FetchReferencesService(stack.client.serializer, stack, resourcePath, collection: collection);
var service = new FetchReferencesService(stack, resourcePath, collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeAsync<FetchReferencesService, ContentstackResponse>(service);
}

Expand All @@ -435,7 +434,7 @@ public virtual ContentstackResponse Publish(PublishUnpublishDetails details, str
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new PublishUnpublishService(stack.client.serializer, stack, details, $"{resourcePath}/publish", "entry", locale);
var service = new PublishUnpublishService(stack, details, $"{resourcePath}/publish", "entry", locale, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeSync(service, apiVersion: apiVersion);
}

Expand All @@ -456,7 +455,7 @@ public virtual Task<ContentstackResponse> PublishAsync(PublishUnpublishDetails d
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new PublishUnpublishService(stack.client.serializer, stack, details, $"{resourcePath}/publish", "entry", locale);
var service = new PublishUnpublishService(stack, details, $"{resourcePath}/publish", "entry", locale, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeAsync<PublishUnpublishService, ContentstackResponse>(service, apiVersion: apiVersion);
}

Expand All @@ -477,7 +476,7 @@ public virtual ContentstackResponse Unpublish(PublishUnpublishDetails details, s
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new PublishUnpublishService(stack.client.serializer, stack, details, $"{resourcePath}/unpublish", "entry", locale);
var service = new PublishUnpublishService(stack, details, $"{resourcePath}/unpublish", "entry", locale, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeSync(service, apiVersion: apiVersion);
}

Expand All @@ -498,7 +497,7 @@ public virtual Task<ContentstackResponse> UnpublishAsync(PublishUnpublishDetails
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new PublishUnpublishService(stack.client.serializer, stack, details, $"{resourcePath}/unpublish", "entry", locale);
var service = new PublishUnpublishService(stack, details, $"{resourcePath}/unpublish", "entry", locale, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeAsync<PublishUnpublishService, ContentstackResponse>(service, apiVersion: apiVersion);
}

Expand All @@ -520,7 +519,7 @@ public ContentstackResponse Import(string filePath, ParameterCollection collecti
stack.ThrowIfNotLoggedIn();

var text = File.ReadAllText(filePath);
var service = new ImportExportService(stack.client.serializer, stack, resourcePath, true, "POST", collection);
var service = new ImportExportService(stack.client.SerializerOptions, stack, resourcePath, true, "POST", collection);
service.ByteContent = System.Text.Encoding.UTF8.GetBytes(text);

return stack.client.InvokeSync(service);
Expand All @@ -545,7 +544,7 @@ public Task<ContentstackResponse> ImportAsync(string filePath, ParameterCollecti
ThrowIfUidEmpty();

var text = File.ReadAllText(filePath);
var service = new ImportExportService(stack.client.serializer, stack, resourcePath, isImport: true, "POST", collection);
var service = new ImportExportService(stack.client.SerializerOptions, stack, resourcePath, isImport: true, "POST", collection);
service.ByteContent = System.Text.Encoding.UTF8.GetBytes(text);
return stack.client.InvokeAsync<ImportExportService, ContentstackResponse>(service);
}
Expand All @@ -569,16 +568,13 @@ public ContentstackResponse Export(string filePath, ParameterCollection collecti

try
{
var service = new ImportExportService(stack.client.serializer, stack, resourcePath, collection: collection);
var service = new ImportExportService(stack.client.SerializerOptions, stack, resourcePath, collection: collection);
ContentstackResponse response = stack.client.InvokeSync(service);
if (response.IsSuccessStatusCode)
{
using (StreamWriter file = File.CreateText(filePath))
using (JsonTextWriter writer = new JsonTextWriter(file))
{
JObject json = response.OpenJObjectResponse();
json.WriteTo(writer);
}
var json = response.OpenJsonObjectResponse();
var opts = new JsonSerializerOptions { WriteIndented = true };
File.WriteAllText(filePath, json.ToJsonString(opts));
}
return response;
} catch (Exception e)
Expand Down Expand Up @@ -609,7 +605,7 @@ public ContentstackResponse SetWorkflow(EntryWorkflowStage model, ParameterColle
{
{ "workflow_stage", model}
};
var service = new CreateUpdateService<Dictionary<string, EntryWorkflowStage>>(stack.client.serializer, stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection);
var service = new CreateUpdateService<Dictionary<string, EntryWorkflowStage>>(stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeSync(service);
}

Expand All @@ -634,7 +630,7 @@ public Task<ContentstackResponse> SetWorkflowAsync(EntryWorkflowStage model, Par
{
{ "workflow_stage", model}
};
var service = new CreateUpdateService<Dictionary<string, EntryWorkflowStage>>(stack.client.serializer, stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection);
var service = new CreateUpdateService<Dictionary<string, EntryWorkflowStage>>(stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeAsync<CreateUpdateService<Dictionary<string, EntryWorkflowStage>>, ContentstackResponse>(service);
}

Expand All @@ -659,7 +655,7 @@ public ContentstackResponse PublishRequest(EntryPublishAction publishAction, Par
{
{ "publishing_rule", publishAction}
};
var service = new CreateUpdateService<Dictionary<string, EntryPublishAction>>(stack.client.serializer, stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection);
var service = new CreateUpdateService<Dictionary<string, EntryPublishAction>>(stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeSync(service);
}
/// <summary>
Expand All @@ -683,7 +679,7 @@ public Task<ContentstackResponse> PublishRequestAsync(EntryPublishAction publish
{
{ "publishing_rule", publishAction}
};
var service = new CreateUpdateService<Dictionary<string, EntryPublishAction>>(stack.client.serializer, stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection);
var service = new CreateUpdateService<Dictionary<string, EntryPublishAction>>(stack, $"{resourcePath}/workflow", dict, "workflow", collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeAsync<CreateUpdateService<Dictionary<string, EntryPublishAction>>, ContentstackResponse>(service);
}
}
Expand Down
12 changes: 6 additions & 6 deletions Contentstack.Management.Core/Models/EntryVariant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ContentstackResponse Create(object model, ParameterCollection collection
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new CreateUpdateService<object>(stack.client.serializer, stack, resourcePath, model, "entry", "PUT", collection: collection);
var service = new CreateUpdateService<object>(stack, resourcePath, model, "entry", "PUT", collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeSync(service);
}

Expand All @@ -101,7 +101,7 @@ public Task<ContentstackResponse> CreateAsync(object model, ParameterCollection
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new CreateUpdateService<object>(stack.client.serializer, stack, resourcePath, model, "entry", "PUT", collection: collection);
var service = new CreateUpdateService<object>(stack, resourcePath, model, "entry", "PUT", collection: collection, stjOptions: stack.client.SerializerOptions);
return stack.client.InvokeAsync<CreateUpdateService<object>, ContentstackResponse>(service);
}

Expand Down Expand Up @@ -137,7 +137,7 @@ public ContentstackResponse Fetch(ParameterCollection collection = null)
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new FetchDeleteService(stack.client.serializer, stack, resourcePath, collection: collection);
var service = new FetchDeleteService(stack, resourcePath, collection: collection);
return stack.client.InvokeSync(service);
}

Expand All @@ -151,7 +151,7 @@ public Task<ContentstackResponse> FetchAsync(ParameterCollection collection = nu
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new FetchDeleteService(stack.client.serializer, stack, resourcePath, collection: collection);
var service = new FetchDeleteService(stack, resourcePath, collection: collection);
return stack.client.InvokeAsync<FetchDeleteService, ContentstackResponse>(service);
}

Expand All @@ -165,7 +165,7 @@ public ContentstackResponse Delete(ParameterCollection collection = null)
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new FetchDeleteService(stack.client.serializer, stack, resourcePath, "DELETE", collection: collection);
var service = new FetchDeleteService(stack, resourcePath, "DELETE", collection: collection);
return stack.client.InvokeSync(service);
}

Expand All @@ -179,7 +179,7 @@ public Task<ContentstackResponse> DeleteAsync(ParameterCollection collection = n
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();

var service = new FetchDeleteService(stack.client.serializer, stack, resourcePath, "DELETE", collection: collection);
var service = new FetchDeleteService(stack, resourcePath, "DELETE", collection: collection);
return stack.client.InvokeAsync<FetchDeleteService, ContentstackResponse>(service);
}

Expand Down
Loading
Loading