Esempio n. 1
0
        public float getCurrentWeather(string cityName, EndpointType endpoint)
        {
            AccuWeatherController accuweatherController = new AccuWeatherController();

            List <float> coordinates = accuweatherController.getCoordinates(cityName);



            float temperature = 0f;

            restClient.endpoint = climaCellEndpoint.getByCityNameEndpoint(coordinates[0], coordinates[1], EndpointType.CURRENT);
            string response = restClient.makeRequest();

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

            ClimaCellWeatherModel deserialisedClimaCellModel = new ClimaCellWeatherModel();

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

            temperature = deserialisedClimaCellModel.temp.value;

            climaCellEndpoint.getByCityNameEndpointForecast(coordinates[0], coordinates[1], EndpointType.FORECAST);

            return(temperature);
        }
Esempio n. 2
0
        public float getCurrentWeather(string latitude, string longitude, EndpointTypes endpointTypes)
        {
            restClient.endpoint = climaCellEndpoint.getCurrentWeather(latitude, longitude, endpointTypes);
            string response = restClient.makeRequest();

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

            ClimaCellWeatherModel deserialisedClimaCellWeatherModel = jsonParser.ParseJSON(response, Parser.Version.NETCore3);

            float value = deserialisedClimaCellWeatherModel.temp.value;

            return(value);
        }