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

DYN-7571 Add Compatibility Map route as an API #114

Merged
merged 3 commits into from
Oct 14, 2024
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
35 changes: 35 additions & 0 deletions src/GregClient/Requests/GetCompatibilityMap.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Returns the compatibility information with a fixed map of host applications
/// and it's respective supported Dynamo version
/// </summary>
public class GetCompatibilityMap : Request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you add some comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
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)
{
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this override still required if not implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, required as we are extending the abstract class Request

}
}
14 changes: 14 additions & 0 deletions src/GregClientTests/GregClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<object>(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()
Expand Down