-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMappingHelper.cs
More file actions
51 lines (40 loc) · 1.49 KB
/
MappingHelper.cs
File metadata and controls
51 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Explore.Cli.Models;
using Explore.Cli.Models.Explore;
public static class MappingHelper
{
public static Connection MassageConnectionExportForImport(Connection? exportedConnection)
{
if (exportedConnection == null)
{
return new Connection();
}
//connection type is not set on exports, yet it needed when sending back to Explore
exportedConnection.Type = "ConnectionRequest";
return exportedConnection;
}
public static Endpoint MassageEndpointExportForImport(Endpoint? exportedEndpoint)
{
if( exportedEndpoint == null)
{
return new Endpoint();
}
//connection type is not set on exports, yet it needed when sending back to Explore
if( exportedEndpoint.Connection == null)
{
exportedEndpoint.Connection = new Connection();
}
exportedEndpoint.Connection.Type = "ConnectionRequest";
return exportedEndpoint;
}
// Helper to map StagedAPI into an ExploreContracts.APIRequestV2
public static ApiRequestV2 MapStagedApiToApiRequestV2(StagedAPI stagedApi)
{
return new ApiRequestV2
{
Name = !string.IsNullOrEmpty(stagedApi.APIName)
? (stagedApi.APIName.Length > 60 ? stagedApi.APIName.Substring(0, 60) : stagedApi.APIName)
: string.Empty,
ServerURLs = new string[] { stagedApi.APIUrl }
};
}
}