public List <WeatherBitForecast> getWeatherForecast(string cityName) { List <WeatherBitForecast> forecastList = new List <WeatherBitForecast>(); restClient.endpoint = weatherBitEndpoint.getWeatherForecast(cityName); string response = restClient.makeRequest(); JSONParser <WeatherBitForecastModel> jsonParser = new JSONParser <WeatherBitForecastModel>(); WeatherBitForecastModel deserialisedWeatherBitForecastModel = jsonParser.ParseJSON(response, Parser.Version.NETCore3); foreach (Dataf data in deserialisedWeatherBitForecastModel.data) { forecastList.Add(new WeatherBitForecast(data.datetime, data.min_temp, data.max_temp)); } return(forecastList); }
public List <WeatherBitForecast> getForecastList(string cityName) { List <WeatherBitForecast> forecastList = new List <WeatherBitForecast>(); restClient.endpoint = weatherBitEndpoint.getForecastEndpoint(cityName); string response = restClient.makeRequest(); JSONParser <WeatherBitForecastModel> jsonParser = new JSONParser <WeatherBitForecastModel>(); WeatherBitForecastModel deserializedWeatherBitForecastModel = new WeatherBitForecastModel(); deserializedWeatherBitForecastModel = jsonParser.parseJSON(response, Parser.Version.NETCore2); foreach (UnnamedObject forecastMain in deserializedWeatherBitForecastModel.list) { DateTime dateTime = DateTime.Parse(forecastMain.datetime); forecastList.Add(new WeatherBitForecast(dateTime, forecastMain.temp)); } return(forecastList); }
public List <WeatherBitForecast> getForecastList(string city, EndpointType endpoint) { List <WeatherBitForecast> forecastList = new List <WeatherBitForecast>(); restClient.endpoint = weatherBitEndpoint.getByCityNameEndpoint(city, endpoint); string response = restClient.makeRequest(); JSONParser <WeatherBitForecastModel> jsonParser = new JSONParser <WeatherBitForecastModel>(); WeatherBitForecastModel deserialisedWeatherBitMapModel = new WeatherBitForecastModel(); deserialisedWeatherBitMapModel = jsonParser.parseJSON(response, Parser.Version.NETCore2); //Console.WriteLine(deserialisedWeatherBitMapModel); foreach (BitForecastObj forecastMain in deserialisedWeatherBitMapModel.data) { //DateTime dt = DateTimeOffset.FromUnixTimeSeconds(forecastMain.datetime).UtcDateTime; DateTime dt = DateTime.Parse(forecastMain.datetime); //Console.WriteLine(dt); forecastList.Add(new WeatherBitForecast(dt, forecastMain.min_temp, forecastMain.max_temp)); } return(forecastList); }