This commit is contained in:
37
util.cs
37
util.cs
@@ -82,6 +82,26 @@ namespace raven_integration
|
||||
return API_BASE_URL + route;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the path to the server root with route appended
|
||||
/// this is used to fetch non-api docs etc
|
||||
/// </summary>
|
||||
/// <param name="route"></param>
|
||||
/// <returns></returns>
|
||||
public static string CleanNonApiRoute(string route)
|
||||
{
|
||||
// public static string API_BASE_URL = "http://localhost:7575/api/v8/";
|
||||
//public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/";
|
||||
|
||||
|
||||
if (!route.StartsWith('/'))
|
||||
{
|
||||
route = "/" + route;
|
||||
}
|
||||
|
||||
return API_BASE_URL.Split("/api/")[0] + route;
|
||||
}
|
||||
|
||||
public async static Task<ApiResponse> GetAsync(string route, string authToken = null, string bodyJsonData = null)
|
||||
{
|
||||
init();
|
||||
@@ -117,6 +137,19 @@ namespace raven_integration
|
||||
return new ApiTextResponse() { HttpResponse = response, TextResponse = responseAsString };
|
||||
}
|
||||
|
||||
|
||||
public async static Task<ApiTextResponse> GetNonApiPageAsync(string route)
|
||||
{
|
||||
init();
|
||||
var requestMessage = new HttpRequestMessage(HttpMethod.Get, CleanNonApiRoute(route));
|
||||
HttpResponseMessage response = await client.SendAsync(requestMessage);
|
||||
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||
return new ApiTextResponse() { HttpResponse = response, TextResponse = responseAsString };
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static async Task<HttpResponseMessage> DownloadFileAsync(string route, string authToken = null)
|
||||
{
|
||||
|
||||
@@ -507,9 +540,9 @@ namespace raven_integration
|
||||
/// <returns></returns>
|
||||
public static string UserRequiredCustomFieldsJsonString()
|
||||
{
|
||||
//Note c1 is only required custom, c2 is defined but is not required so skipping it here
|
||||
//Note c1 is only required custom, c2 is defined but is not required so skipping it here
|
||||
dynamic dCustomField = new JObject();
|
||||
dCustomField.c1 = "UnitTestUtilSampleText";
|
||||
dCustomField.c1 = "UnitTestUtilSampleText";
|
||||
return dCustomField.ToString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user