Get Readings (deprecated) / Get Recent


Static Host Value

      
            static string _host = "https://astuteincservices.com";
        
    

A method named LogMeIn() returns an instance of DGLogInRequest with your credentials.


C# HTTP

        
            if (!string.IsNullOrEmpty(Settings._hub) && Settings._hub.All(char.IsDigit))
            {
                using (HttpClient apiClient = new HttpClient())
                {
                    var token = Settings.GetAuthentication();

                    var json = JsonConvert.SerializeObject(Settings._user);
                    var strContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
                    apiClient.DefaultRequestHeaders.Clear();
                    apiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    var fullData = new DGHubSecurityCodeWithLoginRequest
                    {
                        LoginRequest = Settings._user,
                        IMEI = Settings._hub,
                        SecurityCode = Settings._pinCode
                    };

                    json = JsonConvert.SerializeObject(fullData);
                    strContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

                    var response = apiClient.PostAsync($"{Settings._host}{route}/glucometer-security-code", strContent).Result;

                    Console.WriteLine(response.StatusCode);

                    var reply = response.Content.ReadAsStringAsync().Result;

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        if (!reply.StartsWith("ERROR:"))
                            Console.WriteLine("Glucometer Security Code not assigned");
                        else
                            Console.WriteLine(reply);
                    }
                    else
                    {
                        Console.WriteLine("-------------------");
                        Console.WriteLine(reply);
                    }
                }
            }
        
    

C# Flurl

        
            if (!string.IsNullOrEmpty(Settings._hub) && Settings._hub.All(char.IsDigit))
            {
                var token = Settings.FlurlGetAuthentication();

                var fullData = new DGHubSecurityCodeWithLoginRequest
                {
                    LoginRequest = Settings._user,
                    IMEI = Settings._hub,
                    SecurityCode = Settings._pinCode
                };

                var response = Settings._host.AppendPathSegment($"{route}/glucometer-security-code")
                                             .WithOAuthBearerToken(token)
                                             .PostJsonAsync(fullData).Result;

                Console.WriteLine(response.StatusCode);

                var reply = response.Content.ReadAsStringAsync().Result;

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    if (!reply.StartsWith("ERROR:"))
                        Console.WriteLine("Glucometer Security Code not assigned");
                    else
                        Console.WriteLine(reply);
                }
                else
                {
                    Console.WriteLine("-------------------");
                    Console.WriteLine(reply);
                }
            }