public static bool PostRequest <R, T>(ObserveCredential connection, string requestUri, params T[] content) where R : class, new()
        {
            var data = ParseRequestContent(content);

            var contentStr = new StringContent(data, Encoding.UTF8, "application/json");

            var response = GetClient(connection).PostAsync(requestUri, contentStr).Result;

            return(CheckResponse(response) == null);
        }
        private static HttpClient GetClient(ObserveCredential credential)
        {
            var httpClient = new HttpClient {
                BaseAddress = new Uri($"{credential.BaseUrl}/{credential.PartialUrl}")
            };

            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", credential.Auth);

            return(httpClient);
        }
        private static ObserveCredential GetObserveConnection()
        {
            ObserveCredential connection = CredentialHelper.GetCredentials;

            connection.PartialUrl = "metrics";
            if (connection == null || string.IsNullOrEmpty(connection.Auth) || string.IsNullOrEmpty(connection.BaseUrl))
            {
                return(null);
            }

            return(connection);
        }
        public static bool SendMetrics(params ObserveMetricsData[] metrics)
        {
            ObserveCredential connection = GetObserveConnection();

            if (connection == null)
            {
                return(false);
            }

            try
            {
                return(PostRequest <object, ObserveMetricsData>(connection, "", metrics));
            }
            catch
            {
                return(false);
            }
        }
        public static bool SendProfilerEvent(ObserveProfilerEvent profilerEvent)
        {
            ObserveCredential connection = GetObserveConnection();

            if (connection == null)
            {
                return(false);
            }

            try
            {
                return(PostRequest <object, ObserveProfilerEvent>(connection, "", profilerEvent));
            }
            catch (Exception ex)
            {
                LogConstants.SERVICE_LAYER.Error(ex, "There was an error sending a Profiler Event to Observe.");
                return(false);
            }
        }
        public static bool SendLog(params ObserveLogData[] logs)
        {
            ObserveCredential connection = CredentialHelper.GetCredentials;

            connection.PartialUrl = "logs";
            if (connection == null || string.IsNullOrEmpty(connection.Auth) ||
                string.IsNullOrEmpty(connection.BaseUrl))
            {
                return(false);
            }
            try
            {
                var res = PostRequest <Object, ObserveLogData>(connection, "", logs);
                return(res);
            }
            catch
            {
                return(false);
            }
        }