public async Task <MonitorData> GetMonitorDataAsync(Parameters.MonitorParameters parameters)
        {
            #region "Parameter check"
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            #endregion

            var url = parameters.GetStringFromParameters(MonitorApiLink, ApiKey);
            if (client == null)
            {
                client = new HttpClient();
            }

            var response = await client.GetStringAsync(url).ConfigureAwait(false);

            return(response != null?JsonConvert.DeserializeObject <MonitorData>(response) : null);
        }
Esempio n. 2
0
        public async Task <MonitorData> GetMonitorDataAsync(Parameters.MonitorParameters parameters)
        {
            #region "Parameter check"
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            #endregion

            var url = parameters.GetStringFromParameters(MonitorApiLink, _apiKey);
            if (_client == null)
            {
                _client = new HttpClient();
            }

            var response = await _client.GetStringAsync(url).ConfigureAwait(false);

            var deserialized = JsonConvert.DeserializeObject <MonitorData>(response);
            if (deserialized.Message != null && !deserialized.Message.Value.Equals("OK"))
            {
                throw new RealtimeError(deserialized.Message.MessageCode);
            }
            return(response != null ? deserialized : null);
        }