mirror of
https://github.com/Prominence/openweathermap-java-api.git
synced 2026-07-03 03:06:45 +03:00
Merged changes from dev branch.
This commit is contained in:
@@ -23,16 +23,14 @@
|
||||
package com.github.prominence.openweathermap.api;
|
||||
|
||||
import com.github.prominence.openweathermap.api.annotation.SubscriptionAvailability;
|
||||
import com.github.prominence.openweathermap.api.conf.TimeoutSettings;
|
||||
import com.github.prominence.openweathermap.api.request.RequestSettings;
|
||||
import com.github.prominence.openweathermap.api.request.air.pollution.AirPollutionRequester;
|
||||
import com.github.prominence.openweathermap.api.request.air.pollution.AirPollutionRequesterImpl;
|
||||
import com.github.prominence.openweathermap.api.request.forecast.free.FiveDayThreeHourStepForecastRequester;
|
||||
import com.github.prominence.openweathermap.api.request.forecast.free.FiveDayThreeHourStepForecastRequesterImpl;
|
||||
import com.github.prominence.openweathermap.api.request.onecall.OneCallWeatherRequester;
|
||||
import com.github.prominence.openweathermap.api.request.onecall.OneCallWeatherRequesterImpl;
|
||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequester;
|
||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequesterImpl;
|
||||
|
||||
import static com.github.prominence.openweathermap.api.enums.SubscriptionPlan.*;
|
||||
import static com.github.prominence.openweathermap.api.enums.SubscriptionPlan.ALL;
|
||||
|
||||
/**
|
||||
* The main public API client to communicate with OpenWeatherMap services.
|
||||
@@ -40,6 +38,7 @@ import static com.github.prominence.openweathermap.api.enums.SubscriptionPlan.*;
|
||||
*/
|
||||
public class OpenWeatherMapClient {
|
||||
private final String apiKey;
|
||||
private final TimeoutSettings timeoutSettings = new TimeoutSettings();
|
||||
|
||||
/**
|
||||
* Created OpenWeatherMap client object.
|
||||
@@ -49,13 +48,21 @@ public class OpenWeatherMapClient {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public void setConnectionTimeout(int connectionTimeout) {
|
||||
timeoutSettings.setConnectionTimeout(connectionTimeout);
|
||||
}
|
||||
|
||||
public void setReadTimeout(int readTimeout) {
|
||||
timeoutSettings.setReadTimeout(readTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current Weather <a href="https://openweathermap.org/current">API</a>.
|
||||
* @return requester for retrieving current weather information.
|
||||
*/
|
||||
@SubscriptionAvailability(plans = ALL)
|
||||
public CurrentWeatherRequester currentWeather() {
|
||||
return new CurrentWeatherRequesterImpl(apiKey);
|
||||
return new CurrentWeatherRequester(new RequestSettings(apiKey, timeoutSettings));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +71,7 @@ public class OpenWeatherMapClient {
|
||||
*/
|
||||
@SubscriptionAvailability(plans = ALL)
|
||||
public FiveDayThreeHourStepForecastRequester forecast5Day3HourStep() {
|
||||
return new FiveDayThreeHourStepForecastRequesterImpl(apiKey);
|
||||
return new FiveDayThreeHourStepForecastRequester(new RequestSettings(apiKey, timeoutSettings));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +81,7 @@ public class OpenWeatherMapClient {
|
||||
*/
|
||||
@SubscriptionAvailability(plans = ALL)
|
||||
public OneCallWeatherRequester oneCall() {
|
||||
return new OneCallWeatherRequesterImpl(apiKey);
|
||||
return new OneCallWeatherRequester(new RequestSettings(apiKey, timeoutSettings));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,6 +91,6 @@ public class OpenWeatherMapClient {
|
||||
*/
|
||||
@SubscriptionAvailability(plans = ALL)
|
||||
public AirPollutionRequester airPollution() {
|
||||
return new AirPollutionRequesterImpl(apiKey);
|
||||
return new AirPollutionRequester(new RequestSettings(apiKey, timeoutSettings));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user