static string _host = "https://astuteincservices.com";
A method named LogMeIn() returns an instance of DGLogInRequest with your credentials.
static void TurnOnHub(string token)
{
HttpClient apiClient = new HttpClient();
string route = "/api/hub";
var json = JsonConvert.SerializeObject(LogMeIn());
var strContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
apiClient.DefaultRequestHeaders.Clear();
apiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var response = apiClient.PostAsync(_host + route + "/TurnOn/352753091969608", strContent).Result;
Console.WriteLine(response.StatusCode);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
if (string.IsNullOrEmpty(response.Content.ReadAsStringAsync().Result))
Console.WriteLine("Hub Turned Off");
else
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
else
{
Console.WriteLine("-------------------");
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
}
static void FlurlTurnOnHub(string token)
{
var response = _host.AppendPathSegment("/api/hub/TurnOn/352753091969608").WithOAuthBearerToken(token).PostJsonAsync(LogMeIn()).Result;
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
if (string.IsNullOrEmpty(response.Content.ReadAsStringAsync().Result))
Console.WriteLine("Hub Turned Off");
else
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
}