diff --git a/src/GregClient/Requests/PackageUploadRequestBody.cs b/src/GregClient/Requests/PackageUploadRequestBody.cs index 5e4d3c5..db12dc5 100644 --- a/src/GregClient/Requests/PackageUploadRequestBody.cs +++ b/src/GregClient/Requests/PackageUploadRequestBody.cs @@ -16,12 +16,13 @@ public PackageUploadRequestBody(string name, string version, string description, string metadata, string group, IEnumerable dependencies, string siteUrl, string repositoryUrl, bool containsBinaries, IEnumerable nodeLibraryNames, IEnumerable hostDependencies, - string copyright_holder, string copyright_year, string releaseNotesUrl) + string copyright_holder, string copyright_year, string releaseNotesUrl, IEnumerable compatibilityMatrix) { this.host_dependencies = hostDependencies; this.copyright_holder = copyright_holder; this.copyright_year = copyright_year; this.release_notes_url = releaseNotesUrl; + this.compatibility_matrix = compatibilityMatrix; this.name = name; this.version = version; diff --git a/src/GregClient/Requests/PackageVersionUpload.cs b/src/GregClient/Requests/PackageVersionUpload.cs index ad5f4b6..cda922b 100644 --- a/src/GregClient/Requests/PackageVersionUpload.cs +++ b/src/GregClient/Requests/PackageVersionUpload.cs @@ -79,4 +79,18 @@ public PackageDependency(string name, string version) public string name { get; set; } public string version { get; set; } } + public class PackageCompatibility + { + public PackageCompatibility(string name, List versions, string min, string max) + { + this.name = name; + this.versions = versions; + this.min = min; + this.max = max; + } + public string name { get; set; } + public List versions { get; set; } + public string min { get; set; } + public string max { get; set; } + } } diff --git a/src/GregClient/Requests/PackageVersionUploadRequestBody.cs b/src/GregClient/Requests/PackageVersionUploadRequestBody.cs index 675182c..51e5af5 100644 --- a/src/GregClient/Requests/PackageVersionUploadRequestBody.cs +++ b/src/GregClient/Requests/PackageVersionUploadRequestBody.cs @@ -38,7 +38,7 @@ public PackageVersionUploadRequestBody(string name, string version, string descr string metadata, string group, IEnumerable dependencies, string siteUrl, string repositoryUrl, bool containsBinaries, IEnumerable nodeLibraryNames, IEnumerable hostDependencies, - string copyright_holder, string copyright_year, string compatibility_matrix, string releaseNotesUrl) + string copyright_holder, string copyright_year, IEnumerable compatibilityMatrix, string releaseNotesUrl) { this.host_dependencies = hostDependencies; @@ -60,6 +60,7 @@ public PackageVersionUploadRequestBody(string name, string version, string descr this.node_libraries = nodeLibraryNames; this.compatibility_matrix = compatibility_matrix; this.release_notes_url = releaseNotesUrl; + this.compatibility_matrix = compatibilityMatrix; } /// @@ -132,7 +133,7 @@ public PackageVersionUploadRequestBody(string name, string version, string descr public IEnumerable node_libraries { get; set; } public string copyright_holder { get; set; } public string copyright_year { get; set; } - public string compatibility_matrix { get; set; } + public IEnumerable compatibility_matrix { get; set; } public string release_notes_url { get; set; } } } \ No newline at end of file diff --git a/src/GregClient/Responses/Responses.cs b/src/GregClient/Responses/Responses.cs index 0f88309..c5baf26 100644 --- a/src/GregClient/Responses/Responses.cs +++ b/src/GregClient/Responses/Responses.cs @@ -3,7 +3,6 @@ using RestSharp; using Greg.Converters; using System.Text.Json; -using System.Text.Json.Serialization; namespace Greg.Responses { @@ -78,6 +77,13 @@ public class Dependency public string _id { get; set; } } + public class Compatibility + { + public string name { get; set; } + public List versions { get; set; } + public string min { get; set; } + public string max { get; set; } + } public class PackageVersion { @@ -125,6 +131,7 @@ public class PackageVersion public string size { get; set; } public string release_notes_url { get; set; } + public List compatibility_matrix { get; set; } } public class User diff --git a/src/GregClientTests/GregClientTests.cs b/src/GregClientTests/GregClientTests.cs index e3da1b5..1ce0066 100644 --- a/src/GregClientTests/GregClientTests.cs +++ b/src/GregClientTests/GregClientTests.cs @@ -56,11 +56,11 @@ public void UploadDynamoPackageVersionTest() var keywords = new List() { "neat", "ok" }; var nv = new PackageVersionUploadRequestBody("Third .NET Package", "2.1.0", "", keywords, "contents", "dynamo", "0.1.0", "metadata", "group", new List() { new PackageDependency("peter", "0.1.0"), new PackageDependency("stephen", "0.1.0") }, "", "", - false, new List(), new List(), "Dynamo Team", "2021","",""); + false, new List(), new List(), "Dynamo Team", "2021",null,""); var files = new List() { "../test/pedro.dyf", "../test/RootNode.dyf" }; var request = new PackageVersionUpload(nv, files); - Assert.That(request.RequestBody.AsJson().Equals("{\"file_hash\":null,\"name\":\"Third .NET Package\",\"version\":\"2.1.0\",\"description\":\"\",\"group\":\"group\",\"keywords\":[\"neat\",\"ok\"],\"dependencies\":[{\"name\":\"peter\",\"version\":\"0.1.0\"},{\"name\":\"stephen\",\"version\":\"0.1.0\"}],\"host_dependencies\":[],\"contents\":\"contents\",\"engine_version\":\"0.1.0\",\"engine\":\"dynamo\",\"engine_metadata\":\"metadata\",\"site_url\":\"\",\"repository_url\":\"\",\"contains_binaries\":false,\"node_libraries\":[],\"copyright_holder\":\"Dynamo Team\",\"copyright_year\":\"2021\",\"compatibility_matrix\":\"\",\"release_notes_url\":\"\"}")); + Assert.That(request.RequestBody.AsJson().Equals("{\"file_hash\":null,\"name\":\"Third .NET Package\",\"version\":\"2.1.0\",\"description\":\"\",\"group\":\"group\",\"keywords\":[\"neat\",\"ok\"],\"dependencies\":[{\"name\":\"peter\",\"version\":\"0.1.0\"},{\"name\":\"stephen\",\"version\":\"0.1.0\"}],\"host_dependencies\":[],\"contents\":\"contents\",\"engine_version\":\"0.1.0\",\"engine\":\"dynamo\",\"engine_metadata\":\"metadata\",\"site_url\":\"\",\"repository_url\":\"\",\"contains_binaries\":false,\"node_libraries\":[],\"copyright_holder\":\"Dynamo Team\",\"copyright_year\":\"2021\",\"compatibility_matrix\":null,\"release_notes_url\":\"\"}")); Console.WriteLine(request.RequestBody.AsJson()); } @@ -70,11 +70,11 @@ public void UploadDynamoPackageWithHostDependencyTest() var keywords = new List() { "Civil" }; var nv = new PackageVersionUploadRequestBody("Third .NET Package", "2.1.0", "", keywords, "contents", "dynamo", "0.1.0", "metadata", "group", new List() { new PackageDependency("Ram", "0.1.0"), new PackageDependency("Ian", "0.1.0") }, "", "", - false, new List(), new List() { "Civil3D" }, "Dynamo Team", "2021", "", ""); + false, new List(), new List() { "Civil3D" }, "Dynamo Team", "2021", null, ""); var files = new List() { "../test/pedro.dyf", "../test/RootNode.dyf" }; var request = new PackageVersionUpload(nv, files); - Assert.That(request.RequestBody.AsJson().Equals("{\"file_hash\":null,\"name\":\"Third .NET Package\",\"version\":\"2.1.0\",\"description\":\"\",\"group\":\"group\",\"keywords\":[\"Civil\"],\"dependencies\":[{\"name\":\"Ram\",\"version\":\"0.1.0\"},{\"name\":\"Ian\",\"version\":\"0.1.0\"}],\"host_dependencies\":[\"Civil3D\"],\"contents\":\"contents\",\"engine_version\":\"0.1.0\",\"engine\":\"dynamo\",\"engine_metadata\":\"metadata\",\"site_url\":\"\",\"repository_url\":\"\",\"contains_binaries\":false,\"node_libraries\":[],\"copyright_holder\":\"Dynamo Team\",\"copyright_year\":\"2021\",\"compatibility_matrix\":\"\",\"release_notes_url\":\"\"}")); + Assert.That(request.RequestBody.AsJson().Equals("{\"file_hash\":null,\"name\":\"Third .NET Package\",\"version\":\"2.1.0\",\"description\":\"\",\"group\":\"group\",\"keywords\":[\"Civil\"],\"dependencies\":[{\"name\":\"Ram\",\"version\":\"0.1.0\"},{\"name\":\"Ian\",\"version\":\"0.1.0\"}],\"host_dependencies\":[\"Civil3D\"],\"contents\":\"contents\",\"engine_version\":\"0.1.0\",\"engine\":\"dynamo\",\"engine_metadata\":\"metadata\",\"site_url\":\"\",\"repository_url\":\"\",\"contains_binaries\":false,\"node_libraries\":[],\"copyright_holder\":\"Dynamo Team\",\"copyright_year\":\"2021\",\"compatibility_matrix\":null,\"release_notes_url\":\"\"}")); Console.WriteLine(request.RequestBody.AsJson()); } @@ -83,7 +83,7 @@ public void UploadDynamoPackageVersionWithFilesTest() { var keywords = new List() { "neat", "ok" }; var nv = new PackageVersionUploadRequestBody("Third .NET Package", "2.1.0", "", keywords, "contents", "dynamo", "0.1.0", "metadata", "group", - new List() { new PackageDependency("peter", "0.1.0"), new PackageDependency("stephen", "0.1.0") }, "", "", false, new List(), new List(), "", "", "", ""); + new List() { new PackageDependency("peter", "0.1.0"), new PackageDependency("stephen", "0.1.0") }, "", "", false, new List(), new List(), "", "", null, ""); var files = new List() {Assembly.GetExecutingAssembly().Location }; @@ -160,6 +160,37 @@ public void ListHostsTest() Console.WriteLine(JsonSerializer.Serialize(hostsResponse.content)); Assert.That(hostsResponse.content.Count, Is.EqualTo(5)); } - + + [Test] + + public void TestCompatibilityDeserializationTest() + { + var mockResponse= @"[ + { + ""name"" : ""dynamo"", + ""versions"" : [""2.17"",""2.18""], + ""min"" : ""2.17"", + ""max"" : ""3.0"" + }, + { + ""name"" : ""revit"", + ""versions"" : [""2024"",""2025""], + ""min"" : ""2025"" + }, + { + ""name"" : ""civil3d"", + ""min"" : ""2025"", + ""max"" : ""2024"" + }, + { + ""name"" : "".net"", + ""max"" : ""net8"" + } + ]"; + var cm = JsonSerializer.Deserialize>(mockResponse); + Assert.That(cm, !Is.Null); + Assert.That(cm, Has.Count.EqualTo(4)); + } + } } \ No newline at end of file