Add onecall API 3 support to allow access to daily summary (#58)

* bump nexux-staging-maven-plugin version

to resolve the following maven build error:

[INFO] Scanning for projects...
[WARNING] ClassRealm[extension>org.sonatype.plugins:nexus-staging-maven-plugin:1.6.9, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@1d44bcfa]
com.google.inject.CreationException: Unable to create injector, see the following errors:

1) No implementation for com.fasterxml.jackson.databind.ObjectMapper annotated with interface org.eclipse.sisu.inject.TypeArguments$Implicit was bound.
  Did you mean?
    com.fasterxml.jackson.databind.ObjectMapper annotated with @com.google.inject.name.Named(value="org.sonatype.sisu.siesta.jackson.ObjectMapperProvider") bound  at ClassRealm[extension>org.sonatype.plugins:nexus-staging-maven-plugin:1.6.9, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@1d44bcfa] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)

    com.fasterxml.jackson.databind.ObjectMapper bound  at org.eclipse.sisu.wire.LocatorWiring

  at org.eclipse.sisu.wire.LocatorWiring

1 error
    at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist (Errors.java:543)
    at com.google.inject.internal.InternalInjectorCreator.initializeStatically (InternalInjectorCreator.java:159)
    at com.google.inject.internal.InternalInjectorCreator.build (InternalInjectorCreator.java:106)
    at com.google.inject.Guice.createInjector (Guice.java:87)
    at com.google.inject.Guice.createInjector (Guice.java:69)
    at com.google.inject.Guice.createInjector (Guice.java:59)
    at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector (DefaultPlexusContainer.java:481)
    at org.codehaus.plexus.DefaultPlexusContainer.discoverComponents (DefaultPlexusContainer.java:460)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.discoverPluginComponents (DefaultMavenPluginManager.java:436)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupExtensionsRealm (DefaultMavenPluginManager.java:879)
    at org.apache.maven.project.DefaultProjectBuildingHelper.createProjectRealm (DefaultProjectBuildingHelper.java:196)
    at org.apache.maven.project.DefaultModelBuildingListener.buildExtensionsAssembled (DefaultModelBuildingListener.java:100)
    at org.apache.maven.model.building.ModelBuildingEventCatapult$1.fire (ModelBuildingEventCatapult.java:44)
    at org.apache.maven.model.building.DefaultModelBuilder.fireEvent (DefaultModelBuilder.java:1359)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:452)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:432)
    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:583)
    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:372)
    at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:414)
    at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:405)
    at org.apache.maven.graph.DefaultGraphBuilder.build (DefaultGraphBuilder.java:82)
    at org.apache.maven.DefaultMaven.buildGraph (DefaultMaven.java:507)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:219)

* add onecall 3 API

* Changed subscription plan for oneCall3 requester, deprecated oneCall.

* Fixed query parameters encoding.

---------

Co-authored-by: Prominence <alexey.zinchenko@protonmail.com>
This commit is contained in:
dbadia
2024-11-14 03:52:04 -05:00
committed by GitHub
parent 7f60964886
commit 23462b6d77
8 changed files with 215 additions and 8 deletions
@@ -31,6 +31,7 @@ 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.
@@ -80,10 +81,29 @@ 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));
}
/**
* 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)
public OneCallWeatherRequester oneCall3() {
RequestSettings requestSettings = new RequestSettings(apiKey, timeoutSettings);
requestSettings.setUseApi3();
return new OneCallWeatherRequester(requestSettings);
}
/**
* Air Pollution <a href="https://openweathermap.org/api/air-pollution">API</a>.
* Air Pollution API provides current, forecast and historical air pollution data for any coordinates on the globe.