19 lines
471 B
Java
19 lines
471 B
Java
package ru.dima.weather.city;
|
|
|
|
import ru.dima.weather.http.HttpRequester;
|
|
|
|
public class CityByIpResolver {
|
|
|
|
public static final String IP_INFO_URL = "https://ipinfo.io/city";
|
|
|
|
private HttpRequester httpRequester;
|
|
|
|
public CityByIpResolver(HttpRequester httpRequester) {
|
|
this.httpRequester = httpRequester;
|
|
}
|
|
|
|
public String getCurrentCityViaIP() {
|
|
return httpRequester.getString(IP_INFO_URL).replace("\n", "").replace("\r", "");
|
|
}
|
|
}
|