From ce7b0d223d1b338af29bc2867811ba7ced14f707 Mon Sep 17 00:00:00 2001 From: Ashish Aggarwal Date: Mon, 14 Oct 2024 12:06:48 -0400 Subject: [PATCH] DYN-7571 Add Compatibility Map route as an API (#114) * Create GetCompatibilityMap.cs * add test * comments --- .../Requests/GetCompatibilityMap.cs | 35 +++++++++++++++++++ src/GregClientTests/GregClientTests.cs | 14 ++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/GregClient/Requests/GetCompatibilityMap.cs diff --git a/src/GregClient/Requests/GetCompatibilityMap.cs b/src/GregClient/Requests/GetCompatibilityMap.cs new file mode 100644 index 0000000..beddde7 --- /dev/null +++ b/src/GregClient/Requests/GetCompatibilityMap.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using RestSharp; + +namespace Greg.Requests +{ + /// + /// Returns the compatibility information with a fixed map of host applications + /// and it's respective supported Dynamo version + /// + public class GetCompatibilityMap : Request + { + public GetCompatibilityMap() + { + } + + public override string Path + { + get { return "host_map"; } + } + + public override HttpMethod HttpMethod + { + get { return HttpMethod.Get; } + } + + internal override void Build(ref RestRequest request) + { + } + } +} diff --git a/src/GregClientTests/GregClientTests.cs b/src/GregClientTests/GregClientTests.cs index 1ce0066..ed06a90 100644 --- a/src/GregClientTests/GregClientTests.cs +++ b/src/GregClientTests/GregClientTests.cs @@ -2,6 +2,7 @@ using Greg.Requests; using Greg.Responses; using Greg.Utility; +using Newtonsoft.Json.Linq; using RestSharp; using System.Reflection; using System.Text.Json; @@ -161,6 +162,19 @@ public void ListHostsTest() Assert.That(hostsResponse.content.Count, Is.EqualTo(5)); } + [Test] + public void ListCompatibilityMapTest() + { + GregClient pmc = new GregClient(null, "http://dynamopackages.com/"); + var comMap = new GetCompatibilityMap(); + var comMapResponse = pmc.ExecuteAndDeserializeWithContent(comMap); + Assert.That(comMapResponse.content != null, Is.EqualTo(true)); + var content = JsonSerializer.Serialize(comMapResponse.content); + Console.WriteLine(content); + var jsonResp = JArray.Parse(content); + Assert.That(jsonResp.Where(x => ((JObject)x).ContainsKey("Revit") || ((JObject)x).ContainsKey("Civil3D")).Any(), Is.EqualTo(true)); + } + [Test] public void TestCompatibilityDeserializationTest()