コード例 #1
0
        /// <summary>
        /// Get forecast by geo graphical coordinates.
        /// </summary>
        /// <param name="lat">Coordinates in lattitude.</param>
        /// <param name="lon">Coordinates in Longitude.</param>
        /// <returns></returns>
        public async Task <T> ByCoord <T>(string lat, string lon) where T : ForecastBase
        {
            var json = await _client.DownloadStringTaskAsync($"{_urlBase}/{ApiTarget<T>()}?lat{lat}&lon={lon}&appid={_apiKey}&units={_unitString}");

            return(ForecastBase.FromJson <T>(json));
        }
コード例 #2
0
        /// <summary>
        /// Get forecast by ZIP code.
        /// </summary>
        /// <param name="zipCode">Zip code.</param>
        /// <param name="countryCode">Country code (Use ISO 3166 country codes).</param>
        /// <returns></returns>
        public async Task <T> ByZipCode <T>(string zipCode, string countryCode) where T : ForecastBase
        {
            var json = await _client.DownloadStringTaskAsync($"{_urlBase}/{ApiTarget<T>()}?zip={zipCode},{countryCode}&appid={_apiKey}&units={_unitString}");

            return(ForecastBase.FromJson <T>(json));
        }
コード例 #3
0
        /// <summary>
        /// Get forecast by city.
        /// </summary>
        /// <param name="cityId">City code.</param>
        /// <returns></returns>
        public async Task <T> ByCityCode <T>(string cityId) where T : ForecastBase
        {
            var json = await _client.DownloadStringTaskAsync($"{_urlBase}/{ApiTarget<T>()}?id={cityId}&appid={_apiKey}&units={_unitString}");

            return(ForecastBase.FromJson <T>(json));
        }