Skip to content

Commit 3c8b00e

Browse files
authored
Releasing 2.2.0 version.
1 parent f2c672b commit 3c8b00e

30 files changed

+2622
-17
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Free:
66
* Current weather data
77
* 5 day / 3-hour forecast
88
* One Call API
9+
* Air pollution
910

1011
### Will be implemented later:
1112

1213
Free:
13-
* Air pollution
1414
* Geocoding API
1515
* Weather Stations
1616
* Weather Triggers
@@ -26,14 +26,14 @@ Paid:
2626
<dependency>
2727
<groupId>com.github.prominence</groupId>
2828
<artifactId>openweathermap-api</artifactId>
29-
<version>2.1.1</version>
29+
<version>2.2.0</version>
3030
</dependency>
3131
```
3232

3333
### Gradle coordinates:
3434

3535
```groovy
36-
compile('com.github.prominence:openweathermap-api:2.1.1')
36+
compile('com.github.prominence:openweathermap-api:2.2.0')
3737
```
3838

3939
### Documentation
@@ -44,6 +44,7 @@ compile('com.github.prominence:openweathermap-api:2.1.1')
4444
* [OpenWeatherMap Java API - 2.0.1](docs/Release_2.0.1.md)
4545
* [OpenWeatherMap Java API - 2.1.0](docs/Release_2.1.0.md)
4646
* [OpenWeatherMap Java API - 2.1.1](docs/Release_2.1.1.md)
47+
* [OpenWeatherMap Java API - 2.2.0](docs/Release_2.2.0.md)
4748
* [OpenWeatherMap Java API - SNAPSHOT](docs/SNAPSHOT.md)
4849

4950
### License

docs/Release_2.2.0.md

Lines changed: 538 additions & 0 deletions
Large diffs are not rendered by default.

docs/SNAPSHOT.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Current weather data
33
* 5 day / 3-hour forecast
44
* One Call API
5+
* Air Pollution
56

67
### Maven coordinates:
78

@@ -31,6 +32,7 @@ Currently, available APIs are:
3132
* `currentWeather()`
3233
* `forecast5Day3HourStep()`
3334
* `oneCall()`
35+
* `airPollution()`
3436

3537
Default(more or less) customization points:
3638
```java
@@ -420,6 +422,56 @@ You are able to set preferable options(via chain methods) and execute appropriat
420422
| `getRain()` | Returns `Rain` object. Available fields: `oneHourLevel` and `unit`. |
421423
| `getSnow()` | Returns `Snow` object. Available fields: `oneHourLevel` and `unit`. |
422424

425+
#### Air Pollution API
426+
Examples:
427+
```java
428+
final AirPollutionDetails airPollutionDetails = openWeatherClient
429+
.airPollution()
430+
.current()
431+
.byCoordinate(Coordinate.of(53.54, 27.34))
432+
.retrieve()
433+
.asJava();
434+
```
435+
436+
```java
437+
final AirPollutionDetails airPollutionDetails = openWeatherClient
438+
.airPollution()
439+
.historical()
440+
.byCoordinateAndPeriod(Coordinate.of(53.54, 27.34), 1606223802, 1606482999)
441+
.retrieve()
442+
.asJava();
443+
```
444+
445+
`com.github.prominence.openweathermap.api.model.air.pollution.AirPollutionDetails`'s useful public methods(setters are not listed):
446+
447+
| Method | Description |
448+
|-------------------------------|---------------------------------------------------------------------------|
449+
| `getCoordinate()` | Returns `Coordinate` object. Available fields: `latitude`, `longitude`. |
450+
| `getAirPollutionRecords()` | Returns list of `AirPollutionRecord` objects. |
451+
452+
`com.github.prominence.openweathermap.api.model.air.pollution.AirPollutionRecord`'s useful public methods(setters are not listed):
453+
454+
| Method | Description |
455+
|-------------------------------|---------------------------------------------------------------------------|
456+
| `getForecastTime()` | Returns `LocalDateTime` object with air pollution forecast time. |
457+
| `getAirQualityIndex()` | Returns `AirQualityIndex` object. |
458+
| `getCO()` | Returns carbon monoxide concentration value in μg/m^3.s. |
459+
| `getCarbonMonoxide()` | An alias for `getCO()` method. |
460+
| `getNO()` | Returns nitrogen monoxide concentration value in μg/m^3. |
461+
| `getNitrogenMonoxide()` | An alias for `getNO()` method. |
462+
| `getNO2()` | Returns nitrogen dioxide concentration value in μg/m^3. |
463+
| `getNitrogenDioxide()` | An alias for `getNO2()` method. |
464+
| `getO3()` | Returns ozone concentration value in μg/m^3. |
465+
| `getOzone()` | An alias for `getO3()` method. |
466+
| `getSO2()` | Returns sulphur dioxide concentration value in μg/m^3. |
467+
| `getSulphurDioxide()` | An alias for `getSO2()` method. |
468+
| `getPM2_5()` | Returns fine particles matter concentration value in μg/m^3. |
469+
| `getFineParticlesMatter()` | An alias for `getPM2_5()` method. |
470+
| `getPM10()` | Returns coarse particulate matter concentration value in μg/m^3. |
471+
| `getCoarseParticulateMatter()`| An alias for `getPM10()` method. |
472+
| `getNH3()` | Returns ammonia concentration value in μg/m^3. |
473+
| `getAmmonia()` | An alias for `getNH3()` method. |
474+
423475
### Constants and options
424476

425477
#### Language

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.prominence</groupId>
88
<artifactId>openweathermap-api</artifactId>
9-
<version>2.1.1</version>
9+
<version>2.2.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Java OpenWeatherMap API</name>

src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
package com.github.prominence.openweathermap.api;
2424

2525
import com.github.prominence.openweathermap.api.annotation.SubscriptionAvailability;
26+
import com.github.prominence.openweathermap.api.request.air.pollution.AirPollutionRequester;
27+
import com.github.prominence.openweathermap.api.request.air.pollution.AirPollutionRequesterImpl;
2628
import com.github.prominence.openweathermap.api.request.forecast.free.FiveDayThreeHourStepForecastRequester;
2729
import com.github.prominence.openweathermap.api.request.forecast.free.FiveDayThreeHourStepForecastRequesterImpl;
2830
import com.github.prominence.openweathermap.api.request.onecall.OneCallWeatherRequester;
@@ -74,4 +76,14 @@ public FiveDayThreeHourStepForecastRequester forecast5Day3HourStep() {
7476
public OneCallWeatherRequester oneCall() {
7577
return new OneCallWeatherRequesterImpl(apiKey);
7678
}
79+
80+
/**
81+
* Air Pollution <a href="https://openweathermap.org/api/air-pollution">API</a>.
82+
* Air Pollution API provides current, forecast and historical air pollution data for any coordinates on the globe.
83+
* @return requester for air pollution information retrieval.
84+
*/
85+
@SubscriptionAvailability(plans = ALL)
86+
public AirPollutionRequester airPollution() {
87+
return new AirPollutionRequesterImpl(apiKey);
88+
}
7789
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
*
3+
* * Copyright (c) 2021 Alexey Zinchenko
4+
* *
5+
* * Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* * of this software and associated documentation files (the "Software"), to deal
7+
* * in the Software without restriction, including without limitation the rights
8+
* * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* * copies of the Software, and to permit persons to whom the Software is
10+
* * furnished to do so, subject to the following conditions:
11+
* *
12+
* * The above copyright notice and this permission notice shall be included in all
13+
* * copies or substantial portions of the Software.
14+
* *
15+
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* * SOFTWARE.
22+
*
23+
*/
24+
25+
package com.github.prominence.openweathermap.api.enums;
26+
27+
import java.util.Arrays;
28+
import java.util.Optional;
29+
30+
/**
31+
* The enum Air quality index.
32+
*/
33+
public enum AirQualityIndex {
34+
/**
35+
* Good air quality index.
36+
*/
37+
GOOD(1),
38+
/**
39+
* Fair air quality index.
40+
*/
41+
FAIR(2),
42+
/**
43+
* Moderate air quality index.
44+
*/
45+
MODERATE(3),
46+
/**
47+
* Poor air quality index.
48+
*/
49+
POOR(4),
50+
/**
51+
* Very poor air quality index.
52+
*/
53+
VERY_POOR(5);
54+
55+
private final int value;
56+
57+
AirQualityIndex(int index) {
58+
this.value = index;
59+
}
60+
61+
/**
62+
* Gets value.
63+
*
64+
* @return the value
65+
*/
66+
public int getValue() {
67+
return value;
68+
}
69+
70+
/**
71+
* Gets by index.
72+
*
73+
* @param index the index
74+
* @return the by index
75+
*/
76+
public static AirQualityIndex getByIndex(int index) {
77+
final Optional<AirQualityIndex> optionalAirQualityIndex = Arrays.stream(values()).filter(airQualityIndex -> airQualityIndex.getValue() == index).findFirst();
78+
return optionalAirQualityIndex.orElse(null);
79+
}
80+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
*
3+
* * Copyright (c) 2021 Alexey Zinchenko
4+
* *
5+
* * Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* * of this software and associated documentation files (the "Software"), to deal
7+
* * in the Software without restriction, including without limitation the rights
8+
* * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* * copies of the Software, and to permit persons to whom the Software is
10+
* * furnished to do so, subject to the following conditions:
11+
* *
12+
* * The above copyright notice and this permission notice shall be included in all
13+
* * copies or substantial portions of the Software.
14+
* *
15+
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* * SOFTWARE.
22+
*
23+
*/
24+
25+
package com.github.prominence.openweathermap.api.model.air.pollution;
26+
27+
import com.github.prominence.openweathermap.api.model.Coordinate;
28+
29+
import java.util.List;
30+
import java.util.Objects;
31+
32+
/**
33+
* The type Air pollution.
34+
*/
35+
public class AirPollutionDetails {
36+
private Coordinate coordinate;
37+
private List<AirPollutionRecord> airPollutionRecords;
38+
39+
/**
40+
* Gets coordinate.
41+
*
42+
* @return the coordinate
43+
*/
44+
public Coordinate getCoordinate() {
45+
return coordinate;
46+
}
47+
48+
/**
49+
* Sets coordinate.
50+
*
51+
* @param coordinate the coordinate
52+
*/
53+
public void setCoordinate(Coordinate coordinate) {
54+
this.coordinate = coordinate;
55+
}
56+
57+
/**
58+
* Gets air pollution details.
59+
*
60+
* @return the air pollution details
61+
*/
62+
public List<AirPollutionRecord> getAirPollutionRecords() {
63+
return airPollutionRecords;
64+
}
65+
66+
/**
67+
* Sets air pollution details.
68+
*
69+
* @param airPollutionRecords the air pollution details
70+
*/
71+
public void setAirPollutionRecords(List<AirPollutionRecord> airPollutionRecords) {
72+
this.airPollutionRecords = airPollutionRecords;
73+
}
74+
75+
@Override
76+
public boolean equals(Object o) {
77+
if (this == o) return true;
78+
if (o == null || getClass() != o.getClass()) return false;
79+
AirPollutionDetails that = (AirPollutionDetails) o;
80+
return Objects.equals(coordinate, that.coordinate) && Objects.equals(airPollutionRecords, that.airPollutionRecords);
81+
}
82+
83+
@Override
84+
public int hashCode() {
85+
return Objects.hash(coordinate, airPollutionRecords);
86+
}
87+
}

0 commit comments

Comments
 (0)