Skip to content

Commit 80a7811

Browse files
committed
Url Fix In OpenWeatherMapService
1 parent ed3fb37 commit 80a7811

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapService.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,34 @@
1515

1616
public interface OpenWeatherMapService {
1717

18-
String URL_PATH = "/data/2.5/weather";
18+
String CURRENT = "/data/2.5/weather";
19+
String FORECAST = "/data/2.5/forecast";
1920

2021
//Current Weather Endpoints start
21-
@GET(URL_PATH)
22+
@GET(CURRENT)
2223
Call<CurrentWeather> getCurrentWeatherByCityName(@QueryMap Map<String, String> options);
2324

24-
@GET(URL_PATH)
25+
@GET(CURRENT)
2526
Call<CurrentWeather> getCurrentWeatherByCityID(@QueryMap Map<String, String> options);
2627

27-
@GET(URL_PATH)
28+
@GET(CURRENT)
2829
Call<CurrentWeather> getCurrentWeatherByGeoCoordinates(@QueryMap Map<String, String> options);
2930

30-
@GET(URL_PATH)
31+
@GET(CURRENT)
3132
Call<CurrentWeather> getCurrentWeatherByZipCode(@QueryMap Map<String, String> options);
3233

3334
//Current Weather Endpoints end
3435

3536
//Three hour forecast endpoints start
36-
@GET(URL_PATH)
37+
@GET(FORECAST)
3738
Call<ThreeHourForecast> getThreeHourForecastByCityName(@QueryMap Map<String, String> options);
3839

39-
@GET(URL_PATH)
40+
@GET(FORECAST)
4041
Call<ThreeHourForecast> getThreeHourForecastByCityID(@QueryMap Map<String, String> options);
4142

42-
@GET(URL_PATH)
43+
@GET(FORECAST)
4344
Call<ThreeHourForecast> getThreeHourForecastByGeoCoordinates(@QueryMap Map<String, String> options);
4445

45-
@GET(URL_PATH)
46+
@GET(FORECAST)
4647
Call<ThreeHourForecast> getThreeHourForecastByZipCode(@QueryMap Map<String, String> options);
4748
}

sample/src/main/java/com/kwabenaberko/openweathermap/MainActivity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ protected void onCreate(Bundle savedInstanceState) {
2020
setContentView(R.layout.activity_main);
2121

2222
//Instantiate class
23-
OpenWeatherMapHelper helper = new OpenWeatherMapHelper("8787349f0b6f01dc5600be5815623001");
23+
OpenWeatherMapHelper helper = new OpenWeatherMapHelper();
2424

2525
//Set API KEY
26-
//helper.setApiKey(getString(R.string.OPEN_WEATHER_MAP_API_KEY));
26+
helper.setApiKey(getString(R.string.OPEN_WEATHER_MAP_API_KEY));
2727
//Set Units
2828
helper.setUnits(Units.IMPERIAL);
2929
//Set lang
@@ -37,9 +37,8 @@ protected void onCreate(Bundle savedInstanceState) {
3737
helper.getCurrentWeatherByCityName("Accra", new CurrentWeatherCallback() {
3838
@Override
3939
public void onSuccess(CurrentWeather currentWeather) {
40-
Log.v(TAG,
41-
"Coordinates: " + currentWeather.getCoord().getLat() + ", "+currentWeather.getCoord().getLon() +"\n"
42-
+"Weather Description: " + currentWeather.getWeatherArray().get(0).getDescription() + "\n"
40+
Log.v(TAG, "Coordinates: " + currentWeather.getCoord().getLat() + ", "+currentWeather.getCoord().getLon() +"\n"
41+
+"Weather Description: " + currentWeather.getWeather().get(0).getDescription() + "\n"
4342
+"Temperature: " + currentWeather.getMain().getTempMax()+"\n"
4443
+"Wind Speed: " + currentWeather.getWind().getSpeed() + "\n"
4544
+"City, Country: " + currentWeather.getName() + ", " + currentWeather.getSys().getCountry()

0 commit comments

Comments
 (0)