/// <summary> /// Get weather information by City ID /// </summary> /// <typeparam name="T">Generic parameter</typeparam> /// <param name="id">The city ID</param> /// <param name="units">The units</param> /// <param name="language">The language</param> /// <returns>Information about weather</returns> internal async Task <T> GetById <T>(long id, Units units = Units.Standard, Language language = Language.en) { ArgumentValidator.ArgumentNotNull(id, "id"); var requestUrl = OpenWeatherMapUrl + "?id=" + id + "&appid=" + ApiKey + AddMetricSystem(units) + AddLanguage(language); var response = GetRequest(requestUrl); var stringResponse = await response.Content.ReadAsStringAsync(); var weather = JObject.Parse(stringResponse).ToObject <T>(); return(weather); }
/// <summary> /// Gets weather information by geo coordinates /// </summary> /// <typeparam name="T">Generic parameter</typeparam> /// <param name="latitude">The latitude</param> /// <param name="longitude">The longitude</param> /// <param name="units">The units</param> /// <param name="language">The language</param> /// <returns>Information about weather</returns> internal async Task <T> GetByCoordinates <T>(double latitude, double longitude, Units units = Units.Standard, Language language = Language.en) { ArgumentValidator.ArgumentNotNull(latitude, "latitude"); ArgumentValidator.ArgumentNotNull(longitude, "longitude"); var requestUrl = OpenWeatherMapUrl + "?lat=" + latitude + "&lon=" + longitude + "&appid=" + ApiKey + AddMetricSystem(units) + AddLanguage(language); var response = GetRequest(requestUrl); var stringResponse = await response.Content.ReadAsStringAsync(); var weather = JObject.Parse(stringResponse).ToObject <T>(); return(weather); }