Exemplo n.º 1
0
        public async Task <List <LocationDetail> > FindLocationsByLatLon(double latitude, double longitude)
        {
            string text = string.Format("{0},{1}", new object[]
            {
                latitude.ToString("0.0000", CultureInfo.InvariantCulture),
                longitude.ToString("0.0000", CultureInfo.InvariantCulture)

                //latitude.ToString("F"),
                //longitude.ToString("F")
            });
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);
            Uri requestUri         = new Uri(asp.ApiUriRoot, string.Concat(new string[]
            {
                "locations/",
                asp.ApiVersion,
                "/cities/search.json?q=",
                text,
                "&apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode),
                "&details=true"
            }));

            return(await asp.MakeWebRequest <List <LocationDetail> >(requestUri));
        }
Exemplo n.º 2
0
        public async Task <List <IndexGroupMetadata> > GetIndexGroupMetadata(string locationKey)
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);
            Uri requestUri         = new Uri(asp.ApiUriRoot, string.Concat(new string[]
            {
                "indices/",
                asp.ApiVersion,
                "/daily/groups.json?apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode)
            }));

            return(await asp.MakeWebRequest <List <IndexGroupMetadata> >(requestUri));
        }
Exemplo n.º 3
0
        public async Task <List <LocationDetail> > FindLocationsByIpAddress()
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);
            Uri requestUri         = new Uri(asp.ApiUriRoot, string.Concat(new string[]
            {
                "locations/",
                asp.ApiVersion,
                "/cities/ipaddress.json?apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode),
                "&details=true"
            }));

            return(await asp.MakeWebRequest <List <LocationDetail> >(requestUri));
        }
Exemplo n.º 4
0
        public async Task <List <Alert> > GetAlertsDetails(string locationKey)
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);

            Uri requestUri = new Uri(asp.ApiUriRoot, string.Concat(new string[]
            {
                "alerts/",
                asp.ApiVersion,
                "/",
                locationKey,
                ".json?apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode),
                "&details=true"
            }));

            return(await asp.MakeWebRequest <List <Alert> >(requestUri));
        }
Exemplo n.º 5
0
        public async Task <CurrentConditions> GetCurrentConditions(string locationKey)
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);

            Uri requestUri = new Uri(asp.ApiUriRoot, string.Concat(new string[]
            {
                "currentconditions/",
                asp.ApiVersion,
                "/",
                locationKey,
                ".json?apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode),
                "&details=true"
            }));
            List <CurrentConditions> list = await asp.MakeWebRequest <List <CurrentConditions> >(requestUri);

            return(list[0]);
        }
Exemplo n.º 6
0
        public Task <List <HourlyForecast> > GetHourlyForecasts(string locationKey, HourlyForecastQuery hourlyForecastQuery = HourlyForecastQuery.OneDay, bool?metric = null)
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);
            Uri requestUri         = new Uri(asp.ApiUriRoot, string.Concat(new string[]
            {
                "forecasts/",
                asp.ApiVersion,
                "/hourly/",
                LabelAttribute.GetEnumLabelValue(hourlyForecastQuery),
                "/",
                locationKey,
                ".json?apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode),
                "&details=true&metric=",
                asp.ValidateMetric(metric)
            }));

            return(asp.MakeWebRequest <List <HourlyForecast> >(requestUri));
        }
Exemplo n.º 7
0
        public async Task <List <Index> > GetIndices(string locationKey, int indexGroup, DailyForecastQuery dailyForecastQuery = DailyForecastQuery.FiveDay)
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);
            Uri requestUri         = new Uri(asp.ApiUriRoot, string.Concat(new object[]
            {
                "indices/",
                asp.ApiVersion,
                "/daily/",
                LabelAttribute.GetEnumLabelValue(dailyForecastQuery),
                "/",
                locationKey,
                "/groups/",
                indexGroup,
                ".json?apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode),
                "&details=true"
            }));

            return(await asp.MakeWebRequest <List <Index> >(requestUri));
        }
Exemplo n.º 8
0
        public async Task <List <LocationBase> > FindLocationsAutoCompleteText(string query)
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);

            if (string.IsNullOrWhiteSpace(query))
            {
                throw new InvalidOperationException("The search query cannot be empty");
            }
            Uri requestUri = new Uri(asp.ApiUriRoot, string.Concat(new string[]
            {
                "locations/",
                asp.ApiVersion,
                "/cities/autocomplete.json?q=",
                query,
                "&apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode)
            }));

            return(await asp.MakeWebRequest <List <LocationBase> >(requestUri));
        }
Exemplo n.º 9
0
        public async Task <ClubCloud.Afhangen.UILogic.Models.Location> FindLocationByKey(string key)
        {
            ApiServiceProvider asp = new ApiServiceProvider(apiKey, apiUriRoot);

            if (string.IsNullOrWhiteSpace(key))
            {
                throw new InvalidOperationException("The search key cannot be empty");
            }
            Uri requestUri = new Uri(string.Concat(new object[]
            {
                asp.ApiUriRoot,
                "locations/",
                asp.ApiVersion,
                "/",
                key,
                ".json?apikey=",
                asp.ApiKey,
                "&language=",
                asp.ValidateLanguageCode(asp.LanguageCode),
                "&details=true"
            }));

            return(await asp.MakeWebRequest <Location>(requestUri));
        }