mirror of
https://github.com/Prominence/openweathermap-java-api.git
synced 2026-07-03 19:26:43 +03:00
Compare commits
28 Commits
2.4.0
..
93b6b357c1
| Author | SHA1 | Date | |
|---|---|---|---|
| 93b6b357c1 | |||
| c0dd184965 | |||
| 08d0aa091d | |||
| 93ae514550 | |||
| 2a15788569 | |||
| 37d7a2b3f5 | |||
| 6790848c32 | |||
| 23a1fa5a7b | |||
| 1cac951aaa | |||
| 58e648be42 | |||
| f30bcad5dc | |||
| 5793722181 | |||
| 40462397c1 | |||
| 44b543e65c | |||
| 13b20fc7e9 | |||
| 2a531dd683 | |||
| 1e1054903e | |||
| ff5b6c7a33 | |||
| db1cf858d8 | |||
| c2cc110dab | |||
| d4c2472254 | |||
| 380e3e458b | |||
| 246c07db97 | |||
| f19a627313 | |||
| 6438c323ff | |||
| 1cbff68338 | |||
| 1e08f4f8ae | |||
| bfa15fd9fe |
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: "[BUG] Change me"
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
||||||
**Desktop (please complete the following information):**
|
|
||||||
- OS: [e.g. iOS]
|
|
||||||
- Version [e.g. 22]
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
name: Custom issue template
|
|
||||||
about: Describe this issue template's purpose here.
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: "[FEATURE] Change me"
|
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: maven
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
time: "03:00"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
target-branch: dev
|
||||||
@@ -13,10 +13,10 @@ name: "CodeQL"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ dev ]
|
||||||
pull_request:
|
pull_request:
|
||||||
# The branches below must be a subset of the branches above
|
# The branches below must be a subset of the branches above
|
||||||
branches: [ master ]
|
branches: [ dev ]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '27 20 * * 1'
|
- cron: '27 20 * * 1'
|
||||||
|
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
# Contributor Covenant Code of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
We as members, contributors, and leaders pledge to make participation in our
|
|
||||||
community a harassment-free experience for everyone, regardless of age, body
|
|
||||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
||||||
identity and expression, level of experience, education, socio-economic status,
|
|
||||||
nationality, personal appearance, race, religion, or sexual identity
|
|
||||||
and orientation.
|
|
||||||
|
|
||||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
||||||
diverse, inclusive, and healthy community.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to a positive environment for our
|
|
||||||
community include:
|
|
||||||
|
|
||||||
* Demonstrating empathy and kindness toward other people
|
|
||||||
* Being respectful of differing opinions, viewpoints, and experiences
|
|
||||||
* Giving and gracefully accepting constructive feedback
|
|
||||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
||||||
and learning from the experience
|
|
||||||
* Focusing on what is best not just for us as individuals, but for the
|
|
||||||
overall community
|
|
||||||
|
|
||||||
Examples of unacceptable behavior include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery, and sexual attention or
|
|
||||||
advances of any kind
|
|
||||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing others' private information, such as a physical or email
|
|
||||||
address, without their explicit permission
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Enforcement Responsibilities
|
|
||||||
|
|
||||||
Community leaders are responsible for clarifying and enforcing our standards of
|
|
||||||
acceptable behavior and will take appropriate and fair corrective action in
|
|
||||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
||||||
or harmful.
|
|
||||||
|
|
||||||
Community leaders have the right and responsibility to remove, edit, or reject
|
|
||||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
||||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
||||||
decisions when appropriate.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies within all community spaces, and also applies when
|
|
||||||
an individual is officially representing the community in public spaces.
|
|
||||||
Examples of representing our community include using an official e-mail address,
|
|
||||||
posting via an official social media account, or acting as an appointed
|
|
||||||
representative at an online or offline event.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
||||||
reported to the community leaders responsible for enforcement at
|
|
||||||
alexey.zinchenko@protonmail.com.
|
|
||||||
All complaints will be reviewed and investigated promptly and fairly.
|
|
||||||
|
|
||||||
All community leaders are obligated to respect the privacy and security of the
|
|
||||||
reporter of any incident.
|
|
||||||
|
|
||||||
## Enforcement Guidelines
|
|
||||||
|
|
||||||
Community leaders will follow these Community Impact Guidelines in determining
|
|
||||||
the consequences for any action they deem in violation of this Code of Conduct:
|
|
||||||
|
|
||||||
### 1. Correction
|
|
||||||
|
|
||||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
||||||
unprofessional or unwelcome in the community.
|
|
||||||
|
|
||||||
**Consequence**: A private, written warning from community leaders, providing
|
|
||||||
clarity around the nature of the violation and an explanation of why the
|
|
||||||
behavior was inappropriate. A public apology may be requested.
|
|
||||||
|
|
||||||
### 2. Warning
|
|
||||||
|
|
||||||
**Community Impact**: A violation through a single incident or series
|
|
||||||
of actions.
|
|
||||||
|
|
||||||
**Consequence**: A warning with consequences for continued behavior. No
|
|
||||||
interaction with the people involved, including unsolicited interaction with
|
|
||||||
those enforcing the Code of Conduct, for a specified period of time. This
|
|
||||||
includes avoiding interactions in community spaces as well as external channels
|
|
||||||
like social media. Violating these terms may lead to a temporary or
|
|
||||||
permanent ban.
|
|
||||||
|
|
||||||
### 3. Temporary Ban
|
|
||||||
|
|
||||||
**Community Impact**: A serious violation of community standards, including
|
|
||||||
sustained inappropriate behavior.
|
|
||||||
|
|
||||||
**Consequence**: A temporary ban from any sort of interaction or public
|
|
||||||
communication with the community for a specified period of time. No public or
|
|
||||||
private interaction with the people involved, including unsolicited interaction
|
|
||||||
with those enforcing the Code of Conduct, is allowed during this period.
|
|
||||||
Violating these terms may lead to a permanent ban.
|
|
||||||
|
|
||||||
### 4. Permanent Ban
|
|
||||||
|
|
||||||
**Community Impact**: Demonstrating a pattern of violation of community
|
|
||||||
standards, including sustained inappropriate behavior, harassment of an
|
|
||||||
individual, or aggression toward or disparagement of classes of individuals.
|
|
||||||
|
|
||||||
**Consequence**: A permanent ban from any sort of public interaction within
|
|
||||||
the community.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
||||||
version 2.0, available at
|
|
||||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
||||||
|
|
||||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
||||||
enforcement ladder](https://github.com/mozilla/diversity).
|
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see the FAQ at
|
|
||||||
https://www.contributor-covenant.org/faq. Translations are available at
|
|
||||||
https://www.contributor-covenant.org/translations.
|
|
||||||
@@ -29,14 +29,14 @@ Paid:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.prominence</groupId>
|
<groupId>com.github.prominence</groupId>
|
||||||
<artifactId>openweathermap-api</artifactId>
|
<artifactId>openweathermap-api</artifactId>
|
||||||
<version>2.4.0</version>
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Gradle coordinates:
|
### Gradle coordinates:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
implementation 'com.github.prominence:openweathermap-api:2.4.0'
|
compile('com.github.prominence:openweathermap-api:2.3.0')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
@@ -49,14 +49,14 @@ implementation 'com.github.prominence:openweathermap-api:2.4.0'
|
|||||||
* [OpenWeatherMap Java API - 2.1.1](docs/Release_2.1.1.md)
|
* [OpenWeatherMap Java API - 2.1.1](docs/Release_2.1.1.md)
|
||||||
* [OpenWeatherMap Java API - 2.2.0](docs/Release_2.2.0.md)
|
* [OpenWeatherMap Java API - 2.2.0](docs/Release_2.2.0.md)
|
||||||
* [OpenWeatherMap Java API - 2.3.0](docs/Release_2.3.0.md)
|
* [OpenWeatherMap Java API - 2.3.0](docs/Release_2.3.0.md)
|
||||||
* [OpenWeatherMap Java API - 2.4.0](docs/Release_2.4.0.md)
|
* [OpenWeatherMap Java API - SNAPSHOT](docs/SNAPSHOT.md)
|
||||||
|
|
||||||
### License
|
### License
|
||||||
MIT
|
MIT
|
||||||
|
|
||||||
[ci-shield]: https://travis-ci.org/Prominence/openweathermap-java-api.svg?branch=master
|
[ci-shield]: https://travis-ci.org/Prominence/openweathermap-java-api.svg?branch=dev
|
||||||
[ci-link]: https://travis-ci.org/Prominence/openweathermap-java-api
|
[ci-link]: https://travis-ci.org/Prominence/openweathermap-java-api
|
||||||
|
|
||||||
|
|
||||||
[codecov-shield]: https://codecov.io/gh/Prominence/openweathermap-java-api/branch/master/graph/badge.svg
|
[codecov-shield]: https://codecov.io/gh/Prominence/openweathermap-java-api/branch/dev/graph/badge.svg
|
||||||
[codecov-link]: https://codecov.io/gh/Prominence/openweathermap-java-api
|
[codecov-link]: https://codecov.io/gh/Prominence/openweathermap-java-api
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* Current weather data
|
* Current weather data
|
||||||
* 5 day / 3-hour forecast
|
* 5 day / 3-hour forecast
|
||||||
* One Call API
|
* One Call API
|
||||||
* One Call 3 API
|
|
||||||
* Air Pollution
|
* Air Pollution
|
||||||
|
|
||||||
|
|
||||||
@@ -15,14 +14,14 @@ Other:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.prominence</groupId>
|
<groupId>com.github.prominence</groupId>
|
||||||
<artifactId>openweathermap-api</artifactId>
|
<artifactId>openweathermap-api</artifactId>
|
||||||
<version>2.4.0</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Gradle coordinates:
|
### Gradle coordinates:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
compile('com.github.prominence:openweathermap-api:2.4.0')
|
compile('com.github.prominence:openweathermap-api:3.0.0-SNAPSHOT')
|
||||||
```
|
```
|
||||||
|
|
||||||
### How to use:
|
### How to use:
|
||||||
@@ -213,20 +212,7 @@ A forecast for Minsk with 15 timestamps.
|
|||||||
| `getDayTime()` | Returns enumerations representing the part of day(day, night). |
|
| `getDayTime()` | Returns enumerations representing the part of day(day, night). |
|
||||||
| `toString()` | Returns informative string for the forecast of particular timestamp. |
|
| `toString()` | Returns informative string for the forecast of particular timestamp. |
|
||||||
|
|
||||||
#### One Call 3 API
|
#### One Call API
|
||||||
Examples:
|
|
||||||
```java
|
|
||||||
final CurrentWeatherData currentWeatherData = getClient()
|
|
||||||
.oneCall3()
|
|
||||||
.current()
|
|
||||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
|
||||||
.language(Language.ENGLISH)
|
|
||||||
.unitSystem(UnitSystem.METRIC)
|
|
||||||
.retrieve()
|
|
||||||
.asJava();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### One Call API (Deprecated)
|
|
||||||
Examples:
|
Examples:
|
||||||
```java
|
```java
|
||||||
final CurrentWeatherData currentWeatherData = openWeatherClient
|
final CurrentWeatherData currentWeatherData = openWeatherClient
|
||||||
@@ -560,7 +546,7 @@ final AirPollutionDetails airPollutionDetails = openWeatherClient
|
|||||||
| Unit.STANDARD_SYSTEM | Kelvin, meter/sec, hPa, mm(rain, snow). |
|
| Unit.STANDARD_SYSTEM | Kelvin, meter/sec, hPa, mm(rain, snow). |
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
* com.fasterxml.jackson.core:jackson-databind:2.13.4.2
|
* com.fasterxml.jackson.core:jackson-databind:2.13.2.2
|
||||||
* org.slf4j:slf4j-api:1.7.36 (*compile*)
|
* org.slf4j:slf4j-api:1.7.36 (*compile*)
|
||||||
* org.junit.jupiter:junit-jupiter-engine:5.8.2 (*test*)
|
* org.junit.jupiter:junit-jupiter-engine:5.8.2 (*test*)
|
||||||
* org.junit.platform:junit-platform-runner:1.8.2 (*test*)
|
* org.junit.platform:junit-platform-runner:1.8.2 (*test*)
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.github.prominence</groupId>
|
<groupId>com.github.prominence</groupId>
|
||||||
<artifactId>openweathermap-api</artifactId>
|
<artifactId>openweathermap-api</artifactId>
|
||||||
<version>2.4.0</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Java OpenWeatherMap API</name>
|
<name>Java OpenWeatherMap API</name>
|
||||||
@@ -61,16 +61,16 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.10.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>17</source>
|
||||||
<target>8</target>
|
<target>17</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/test/*</exclude>
|
<exclude>**/test/*</exclude>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.sonatype.plugins</groupId>
|
<groupId>org.sonatype.plugins</groupId>
|
||||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||||
<version>1.6.13</version>
|
<version>1.6.12</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<serverId>ossrh</serverId>
|
<serverId>ossrh</serverId>
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>8</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.7</version>
|
<version>0.8.8</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@@ -163,7 +163,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.13.4.2</version>
|
<version>2.13.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.github.prominence.openweathermap.api.request.onecall.OneCallWeatherRe
|
|||||||
import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequester;
|
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.ALL;
|
||||||
import static com.github.prominence.openweathermap.api.enums.SubscriptionPlan.SPECIAL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main public API client to communicate with OpenWeatherMap services.
|
* The main public API client to communicate with OpenWeatherMap services.
|
||||||
@@ -81,29 +80,10 @@ public class OpenWeatherMapClient {
|
|||||||
* @return requester for retrieving one call weather information.
|
* @return requester for retrieving one call weather information.
|
||||||
*/
|
*/
|
||||||
@SubscriptionAvailability(plans = ALL)
|
@SubscriptionAvailability(plans = ALL)
|
||||||
@Deprecated
|
|
||||||
public OneCallWeatherRequester oneCall() {
|
public OneCallWeatherRequester oneCall() {
|
||||||
return new OneCallWeatherRequester(new RequestSettings(apiKey, timeoutSettings));
|
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 <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.
|
* Air Pollution API provides current, forecast and historical air pollution data for any coordinates on the globe.
|
||||||
|
|||||||
@@ -56,9 +56,4 @@ public enum SubscriptionPlan {
|
|||||||
* All existing subscription plans.
|
* All existing subscription plans.
|
||||||
*/
|
*/
|
||||||
ALL,
|
ALL,
|
||||||
|
|
||||||
/**
|
|
||||||
* Special subscription cases.
|
|
||||||
*/
|
|
||||||
SPECIAL,
|
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -213,7 +213,6 @@ public class OneCallWeatherResponseMapper {
|
|||||||
daily.setMoonPhase(new MoonPhase(moonPhaseNode.asDouble()));
|
daily.setMoonPhase(new MoonPhase(moonPhaseNode.asDouble()));
|
||||||
}
|
}
|
||||||
|
|
||||||
daily.setSummary(parseSummary(dailyNode));
|
|
||||||
daily.setWeatherState(parseWeatherState(dailyNode.get("weather").get(0)));
|
daily.setWeatherState(parseWeatherState(dailyNode.get("weather").get(0)));
|
||||||
daily.setTemperature(parseDailyTemperature(dailyNode));
|
daily.setTemperature(parseDailyTemperature(dailyNode));
|
||||||
daily.setAtmosphericPressure(parsePressure(dailyNode));
|
daily.setAtmosphericPressure(parsePressure(dailyNode));
|
||||||
@@ -440,12 +439,4 @@ public class OneCallWeatherResponseMapper {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parseSummary(JsonNode dailyNode) {
|
|
||||||
final JsonNode summaryNode = dailyNode.get("summary");
|
|
||||||
if(summaryNode != null) {
|
|
||||||
return summaryNode.asText();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-20
@@ -43,7 +43,6 @@ public class Daily {
|
|||||||
private LocalDateTime moonsetTime;
|
private LocalDateTime moonsetTime;
|
||||||
private MoonPhase moonPhase;
|
private MoonPhase moonPhase;
|
||||||
|
|
||||||
private String summary;
|
|
||||||
private WeatherState weatherState;
|
private WeatherState weatherState;
|
||||||
private DailyTemperature temperature;
|
private DailyTemperature temperature;
|
||||||
private AtmosphericPressure atmosphericPressure;
|
private AtmosphericPressure atmosphericPressure;
|
||||||
@@ -163,24 +162,6 @@ public class Daily {
|
|||||||
this.moonPhase = moonPhase;
|
this.moonPhase = moonPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets summary.
|
|
||||||
*
|
|
||||||
* @return the summary
|
|
||||||
*/
|
|
||||||
public String getSummary() {
|
|
||||||
return summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets summary.
|
|
||||||
*
|
|
||||||
* @param summary the summary
|
|
||||||
*/
|
|
||||||
public void setSummary(String summary) {
|
|
||||||
this.summary = summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets weather state.
|
* Gets weather state.
|
||||||
*
|
*
|
||||||
@@ -454,5 +435,4 @@ public class Daily {
|
|||||||
}
|
}
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class RequestSettings {
|
|||||||
|
|
||||||
private Language language = Language.ENGLISH;
|
private Language language = Language.ENGLISH;
|
||||||
private UnitSystem unitSystem = UnitSystem.STANDARD;
|
private UnitSystem unitSystem = UnitSystem.STANDARD;
|
||||||
private boolean useApi3 = false;
|
|
||||||
|
|
||||||
public RequestSettings(String apiKey, TimeoutSettings timeoutSettings) {
|
public RequestSettings(String apiKey, TimeoutSettings timeoutSettings) {
|
||||||
this.putRequestParameter(API_KEY_PARAM_NAME, apiKey);
|
this.putRequestParameter(API_KEY_PARAM_NAME, apiKey);
|
||||||
@@ -95,14 +94,6 @@ public class RequestSettings {
|
|||||||
urlAppenderBuilder.append(appendix);
|
urlAppenderBuilder.append(appendix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseApi3() {
|
|
||||||
this.useApi3 = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getUseApi3() {
|
|
||||||
return this.useApi3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringBuilder getUrlAppender() {
|
public StringBuilder getUrlAppender() {
|
||||||
return urlAppenderBuilder;
|
return urlAppenderBuilder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ import com.github.prominence.openweathermap.api.request.RequestSettings;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public final class RequestUtils {
|
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 = "http://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 Logger logger = LoggerFactory.getLogger(RequestUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(RequestUtils.class);
|
||||||
|
|
||||||
@@ -52,19 +53,10 @@ public final class RequestUtils {
|
|||||||
|
|
||||||
public static String getResponse(RequestSettings requestSettings) {
|
public static String getResponse(RequestSettings requestSettings) {
|
||||||
StringBuilder requestUrlBuilder = new StringBuilder(OWM_URL_BASE);
|
StringBuilder requestUrlBuilder = new StringBuilder(OWM_URL_BASE);
|
||||||
if(requestSettings.getUseApi3()) {
|
|
||||||
requestUrlBuilder = new StringBuilder(OWM_URL_BASE_3_0);
|
|
||||||
}
|
|
||||||
requestUrlBuilder.append(requestSettings.getUrlAppender());
|
requestUrlBuilder.append(requestSettings.getUrlAppender());
|
||||||
requestUrlBuilder.append('?');
|
requestUrlBuilder.append('?');
|
||||||
String parameters = requestSettings.getRequestParameters().entrySet().stream()
|
String parameters = requestSettings.getRequestParameters().entrySet().stream()
|
||||||
.map(entry -> {
|
.map(entry -> entry.getKey() + "=" + entry.getValue())
|
||||||
try {
|
|
||||||
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect(Collectors.joining("&"));
|
.collect(Collectors.joining("&"));
|
||||||
requestUrlBuilder.append(parameters);
|
requestUrlBuilder.append(parameters);
|
||||||
|
|
||||||
|
|||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2021 Alexey Zinchenko
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.github.prominence.openweathermap.api.request.onecall.current;
|
|
||||||
|
|
||||||
import com.github.prominence.openweathermap.api.ApiTest;
|
|
||||||
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
|
||||||
import com.github.prominence.openweathermap.api.enums.Language;
|
|
||||||
import com.github.prominence.openweathermap.api.enums.OneCallResultOptions;
|
|
||||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
|
||||||
import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenException;
|
|
||||||
import com.github.prominence.openweathermap.api.exception.NoDataFoundException;
|
|
||||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
|
||||||
import com.github.prominence.openweathermap.api.model.onecall.current.CurrentWeatherData;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
public class CurrentWeatherOneCallApi3IntegrationTest extends ApiTest {
|
|
||||||
@Test
|
|
||||||
public void whenRetrieveCurrentOneCallResponseAsJava_thenOk() {
|
|
||||||
final CurrentWeatherData currentWeatherData = getClient()
|
|
||||||
.oneCall3()
|
|
||||||
.current()
|
|
||||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
|
||||||
.language(Language.ENGLISH)
|
|
||||||
.unitSystem(UnitSystem.METRIC)
|
|
||||||
.retrieve()
|
|
||||||
.asJava();
|
|
||||||
|
|
||||||
assertNotNull(currentWeatherData);
|
|
||||||
assertNotNull(currentWeatherData.getDailyList().get(0).getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenRetrieveCurrentOneCallResponseAsJSON_thenOk() {
|
|
||||||
final String responseJson = getClient()
|
|
||||||
.oneCall3()
|
|
||||||
.current()
|
|
||||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
|
||||||
.language(Language.ENGLISH)
|
|
||||||
.unitSystem(UnitSystem.METRIC)
|
|
||||||
.retrieve()
|
|
||||||
.asJSON();
|
|
||||||
|
|
||||||
assertNotNull(responseJson);
|
|
||||||
assertNotEquals("", responseJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenRetrieveCurrentOneCallResponseWithExclusionAsJava_thenOk() {
|
|
||||||
final CurrentWeatherData currentWeatherData = getClient()
|
|
||||||
.oneCall3()
|
|
||||||
.current()
|
|
||||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
|
||||||
.language(Language.ENGLISH)
|
|
||||||
.unitSystem(UnitSystem.METRIC)
|
|
||||||
.exclude(OneCallResultOptions.CURRENT, OneCallResultOptions.MINUTELY)
|
|
||||||
.retrieve()
|
|
||||||
.asJava();
|
|
||||||
|
|
||||||
assertNotNull(currentWeatherData);
|
|
||||||
assertNull(currentWeatherData.getCurrent());
|
|
||||||
assertNull(currentWeatherData.getMinutelyList());
|
|
||||||
assertNotNull(currentWeatherData.getDailyList().get(0).getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenRetrieveCurrentOneCallAsyncResponseAsJava_thenOk() throws ExecutionException, InterruptedException {
|
|
||||||
final CompletableFuture<CurrentWeatherData> currentWeatherDataFuture = getClient()
|
|
||||||
.oneCall3()
|
|
||||||
.current()
|
|
||||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
|
||||||
.language(Language.ENGLISH)
|
|
||||||
.unitSystem(UnitSystem.METRIC)
|
|
||||||
.retrieveAsync()
|
|
||||||
.asJava();
|
|
||||||
|
|
||||||
assertNotNull(currentWeatherDataFuture);
|
|
||||||
assertNotNull(currentWeatherDataFuture.get());
|
|
||||||
assertNotNull(currentWeatherDataFuture.get().getDailyList().get(0).getSummary());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenRetrieveCurrentOneCallAsyncResponseAsJSON_thenOk() throws ExecutionException, InterruptedException {
|
|
||||||
final CompletableFuture<String> responseJsonFuture = getClient()
|
|
||||||
.oneCall3()
|
|
||||||
.current()
|
|
||||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
|
||||||
.language(Language.ENGLISH)
|
|
||||||
.unitSystem(UnitSystem.METRIC)
|
|
||||||
.retrieveAsync()
|
|
||||||
.asJSON();
|
|
||||||
|
|
||||||
assertNotNull(responseJsonFuture);
|
|
||||||
final String responseJson = responseJsonFuture.get();
|
|
||||||
assertNotNull(responseJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenRequestOnecallWithInvalidApiKey_thenThrowAnException() {
|
|
||||||
OpenWeatherMapClient client = new OpenWeatherMapClient("invalidKey");
|
|
||||||
assertThrows(InvalidAuthTokenException.class, () ->
|
|
||||||
client
|
|
||||||
.oneCall3()
|
|
||||||
.current()
|
|
||||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
|
||||||
.language(Language.ENGLISH)
|
|
||||||
.unitSystem(UnitSystem.METRIC)
|
|
||||||
.retrieve()
|
|
||||||
.asJSON()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user