Esempio n. 1
0
        public float getCurrentTemperature(string city, EndpointTypes endpointTypes)
        {
            restClient.endpoint = openWeatherMapEndpoint.getByCityNameEndpoint(city, endpointTypes);
            string response = restClient.makeRequest();

            JSONParser <OpenWeatherMapWeatherModel> jsonParser         = new JSONParser <OpenWeatherMapWeatherModel>();
            OpenWeatherMapWeatherModel deserializedOpenWeatherMapModel = jsonParser.ParseJSON(response, Parser.Version.NETCore3);

            float temperature = deserializedOpenWeatherMapModel.main.temp;

            return(temperature);
        }
Esempio n. 2
0
        public OpenWeatherCoordinate getCoordinates(string city)
        {
            restClient.endpoint = openWeatherMapEndpoint.getByCityNameEndpoint(city, EndpointType.CURRENT);
            string response = restClient.makeRequest();

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

            OpenWeatherMapWeatherModel deserialisedOpenWeatherMapModel = new OpenWeatherMapWeatherModel();

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

            return(deserialisedOpenWeatherMapModel.coord);
        }
        public float getCurrentWeather(string city)
        {
            float temperature = 0f;

            openWeatherMapAPIEndpoint.endpointType = EndpointType.WEATHER;

            string response = getResponse(openWeatherMapAPIEndpoint.getByCityNameEndpoint(city));

            System.Diagnostics.Debug.WriteLine(response);

            using (JsonParser <OpenWeatherMapWeatherModel> jsonParser = new JsonParser <OpenWeatherMapWeatherModel>())
            {
                OpenWeatherMapWeatherModel openWeatherMapWeatherModel = new OpenWeatherMapWeatherModel();
                openWeatherMapWeatherModel = jsonParser.parse(response);

                temperature = openWeatherMapWeatherModel.main.temp;
            }

            return(temperature);
        }