Compare commits

..

No commits in common. "d4c255385c8ef775943acd0ed7d9dc6b09c12b8e" and "ac1f043f51639be16817b4cfc06b79492d664000" have entirely different histories.

3 changed files with 8 additions and 25 deletions

View File

@ -31,7 +31,6 @@ import com.github.prominence.openweathermap.api.request.onecall.OneCallWeatherRe
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequester;
import static com.github.prominence.openweathermap.api.enums.SubscriptionPlan.ALL;
import static com.github.prominence.openweathermap.api.enums.SubscriptionPlan.SPECIAL;
/**
* The main public API client to communicate with OpenWeatherMap services.
@ -81,7 +80,6 @@ public class OpenWeatherMapClient {
* @return requester for retrieving one call weather information.
*/
@SubscriptionAvailability(plans = ALL)
@Deprecated
public OneCallWeatherRequester oneCall() {
return new OneCallWeatherRequester(new RequestSettings(apiKey, timeoutSettings));
}
@ -89,15 +87,9 @@ public class OpenWeatherMapClient {
/**
* One Call 3 API <a href="https://openweathermap.org/api/one-call-3">API</a>.
* Includes a weather summary statement in addition to the information provided by {@link #oneCall()}
*
* Please note, that One Call API 3.0 is included in the "One Call by Call" subscription only.
* This separate subscription includes 1,000 calls/day for free and allows you to pay only for the number of API calls made to this product.
* Please note, that you do not need to subscribe to any other OpenWeather subscription plans to get access to the One Call API 3.0.
* Please find more details on the pricing page and FAQ or ask Ulla, OpenWeather AI assistant.
*
* @return requester for retrieving one call weather information for the OneCall 3 API.
*/
@SubscriptionAvailability(plans = SPECIAL)
@SubscriptionAvailability(plans = ALL)
public OneCallWeatherRequester oneCall3() {
RequestSettings requestSettings = new RequestSettings(apiKey, timeoutSettings);
requestSettings.setUseApi3();

View File

@ -56,9 +56,4 @@ public enum SubscriptionPlan {
* All existing subscription plans.
*/
ALL,
/**
* Special subscription cases.
*/
SPECIAL,
}

View File

@ -29,11 +29,13 @@ import com.github.prominence.openweathermap.api.request.RequestSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
@ -42,8 +44,8 @@ import java.util.stream.Collectors;
*/
public final class RequestUtils {
private static final String OWM_URL_BASE = "https://api.openweathermap.org/data/2.5/";
private static final String OWM_URL_BASE_3_0 = "https://api.openweathermap.org/data/3.0/";
private static final String OWM_URL_BASE = "http://api.openweathermap.org/data/2.5/";
private static final String OWM_URL_BASE_3_0 = "http://api.openweathermap.org/data/3.0/";
private static final Logger logger = LoggerFactory.getLogger(RequestUtils.class);
@ -58,13 +60,7 @@ public final class RequestUtils {
requestUrlBuilder.append(requestSettings.getUrlAppender());
requestUrlBuilder.append('?');
String parameters = requestSettings.getRequestParameters().entrySet().stream()
.map(entry -> {
try {
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
})
.map(entry -> entry.getKey() + "=" + entry.getValue())
.collect(Collectors.joining("&"));
requestUrlBuilder.append(parameters);