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

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

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

            return(response != null?JsonConvert.DeserializeObject <TrafficInfoData>(response) : null);
        }
Beispiel #2
0
        public async Task <TrafficInfoData> GetTrafficInfoDataAsync(Parameters.TrafficInfoParameters parameters)
        {
            #region "Parameter check"
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            #endregion
            var url = parameters.GetStringFromParameters(TrafficInfoListApiLink, _apiKey);
            if (_client == null)
            {
                _client = new HttpClient();
            }
            var response = await _client.GetStringAsync(url).ConfigureAwait(false);

            var deserialized = JsonConvert.DeserializeObject <TrafficInfoData>(response);
            if (deserialized.Message != null)
            {
                throw new RealtimeError(deserialized.Message.MessageCode);
            }

            return(response != null ? deserialized : null);
        }