public List <DarkSkyDaily> getForecastDaily(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);
            List <DarkSkyDaily>      forecast       = new List <DarkSkyDaily>();

            restClient.endpoint = darkSkyEndpoint.getForecastEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <DarkSkyForecastModel> jsonParser = new JSONParser <DarkSkyForecastModel>();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            foreach (DarkSkyDailyData deserialisedModel in deserialisedModelList.daily.data)
            {
                forecast.Add(new DarkSkyDaily(
                                 deserialisedModel.time,
                                 deserialisedModel.temperatureHigh,
                                 deserialisedModel.temperatureLow)
                             );
            }

            return(forecast);
        }
        public DarkSky getForecastCurrentTemperature(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);

            restClient.endpoint = darkSkyEndpoint.getForecastEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <DarkSkyForecastModel> jsonParser = new JSONParser <DarkSkyForecastModel>();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            return(new DarkSky(deserialisedModelList.currently.time, deserialisedModelList.currently.temperature));
        }
Example #3
0
        public ClimaCell getCurrent(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);

            restClient.endpoint = climaCellEndpoint.getCurrentEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <ClimaCellCurrentModel> jsonParser = new JSONParser <ClimaCellCurrentModel>();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            return(new ClimaCell(deserialisedModelList.observation_time.value, deserialisedModelList.temp.value));
        }
Example #4
0
        public List <Weather2020> getForecast(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);
            List <Weather2020>       forecast       = new List <Weather2020>();

            restClient.endpoint = weather2020Endpoint.getForecastEndpoint(coords.lon, coords.lat);
            string response = restClient.makeRequest();

            JSONParser <List <Weather2020Model> > jsonParser = new JSONParser <List <Weather2020Model> >();

            List <Weather2020Model> deserialisedModelList = jsonParser.parseJSON(response, Version.NETCore2);

            foreach (Weather2020Model deserialisedModel in deserialisedModelList)
            {
                forecast.Add(new Weather2020(deserialisedModel.startDate, deserialisedModel.temperatureHighCelcius, deserialisedModel.temperatureLowCelcius));
            }

            return(forecast);
        }
Example #5
0
        public List <ClimaCellForecast> getForecast(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);
            List <ClimaCellForecast> forecast       = new List <ClimaCellForecast>();

            restClient.endpoint = climaCellEndpoint.getForecastEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <List <ClimaCellForecastModel> > jsonParser = new JSONParser <List <ClimaCellForecastModel> >();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            foreach (ClimaCellForecastModel model in deserialisedModelList)
            {
                forecast.Add(new ClimaCellForecast(model.observation_time.value, model.temp));
            }

            return(forecast);
        }