diff --git a/LICENSE b/LICENSE index 8ed4b26..c9309fc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Alexey Zinchenko +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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java b/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java index 6fc95c6..59e31f7 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java +++ b/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -22,9 +22,14 @@ package com.github.prominence.openweathermap.api; +import com.github.prominence.openweathermap.api.annotation.SubscriptionAvailability; +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.weather.CurrentWeatherRequester; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequesterImpl; +import static com.github.prominence.openweathermap.api.enums.SubscriptionPlan.*; + public class OpenWeatherMapClient { private final String apiKey; @@ -33,12 +38,19 @@ public class OpenWeatherMapClient { this.apiKey = apiKey; } + @SubscriptionAvailability(plans = ALL) public CurrentWeatherRequester currentWeather() { return new CurrentWeatherRequesterImpl(apiKey); } + @SubscriptionAvailability(plans = ALL) + public FiveDayThreeHourStepForecastRequester forecast5Day3HourStep() { + return new FiveDayThreeHourStepForecastRequesterImpl(apiKey); + } + // TODO: // * Forecast: hourly, daily // * Air Pollution // * Ultraviolet index + // DOCS } diff --git a/src/main/java/com/github/prominence/openweathermap/api/annotation/SubscriptionAvailability.java b/src/main/java/com/github/prominence/openweathermap/api/annotation/SubscriptionAvailability.java new file mode 100644 index 0000000..61d365e --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/annotation/SubscriptionAvailability.java @@ -0,0 +1,36 @@ +/* + * 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.annotation; + +import com.github.prominence.openweathermap.api.enums.SubscriptionPlan; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +public @interface SubscriptionAvailability { + SubscriptionPlan[] plans(); +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java b/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java index 790786a..c4ef6ce 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/Accuracy.java b/src/main/java/com/github/prominence/openweathermap/api/enums/SubscriptionPlan.java similarity index 81% rename from src/main/java/com/github/prominence/openweathermap/api/enums/Accuracy.java rename to src/main/java/com/github/prominence/openweathermap/api/enums/SubscriptionPlan.java index f79c8bd..46fd194 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/Accuracy.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/SubscriptionPlan.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -22,17 +22,11 @@ package com.github.prominence.openweathermap.api.enums; -public enum Accuracy { - LIKE("like"), - ACCURATE("accurate"); - - private final String value; - - Accuracy(String value) { - this.value = value; - } - - public String getValue() { - return value; - } +public enum SubscriptionPlan { + FREE, + STARTUP, + DEVELOPER, + PROFESSIONAL, + ENTERPRISE, + ALL, } diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java b/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java index 058ca63..c133ef7 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java b/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java index b7e4853..3457a1f 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java b/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java index b1e642f..9e7dd20 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java +++ b/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java b/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java index a46b888..4f66b53 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java +++ b/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Clouds.java b/src/main/java/com/github/prominence/openweathermap/api/model/Clouds.java index 554673b..7808262 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Clouds.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Clouds.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Coordinate.java b/src/main/java/com/github/prominence/openweathermap/api/model/Coordinate.java index 5f42724..61327ac 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Coordinate.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Coordinate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/CoordinateRectangle.java b/src/main/java/com/github/prominence/openweathermap/api/model/CoordinateRectangle.java index d47ff57..6027ade 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/CoordinateRectangle.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/CoordinateRectangle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -26,10 +26,10 @@ import java.util.Objects; public class CoordinateRectangle { - private double longitudeLeft; - private double latitudeBottom; - private double longitudeRight; - private double latitudeTop; + private final double longitudeLeft; + private final double latitudeBottom; + private final double longitudeRight; + private final double latitudeTop; public CoordinateRectangle(double longitudeLeft, double latitudeBottom, double longitudeRight, double latitudeTop) { if (latitudeBottom < -90 || latitudeTop < -90 || latitudeBottom > 90 || latitudeTop > 90) { diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Humidity.java b/src/main/java/com/github/prominence/openweathermap/api/model/Humidity.java index b28a6bd..a62fe20 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Humidity.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Humidity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Location.java b/src/main/java/com/github/prominence/openweathermap/api/model/Location.java index 3639dcd..69ddc07 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Location.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Location.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Pressure.java b/src/main/java/com/github/prominence/openweathermap/api/model/Pressure.java index f3b11eb..84c28fd 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Pressure.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Pressure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Rain.java b/src/main/java/com/github/prominence/openweathermap/api/model/Rain.java index 927af43..e146f38 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Rain.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Rain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Snow.java b/src/main/java/com/github/prominence/openweathermap/api/model/Snow.java index 91c7bba..b9660f2 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Snow.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Snow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Temperature.java b/src/main/java/com/github/prominence/openweathermap/api/model/Temperature.java index f68dbd1..9719dbc 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Temperature.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Temperature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Weather.java b/src/main/java/com/github/prominence/openweathermap/api/model/Weather.java index f4bcba0..d94ee11 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Weather.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Weather.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Wind.java b/src/main/java/com/github/prominence/openweathermap/api/model/Wind.java index 4814161..bb62de3 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Wind.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/Wind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/AsyncRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/AsyncRequestTerminator.java new file mode 100644 index 0000000..a216e67 --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/AsyncRequestTerminator.java @@ -0,0 +1,28 @@ +/* + * 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; + +import java.util.concurrent.CompletableFuture; + +public interface AsyncRequestTerminator extends RequestTerminator, CompletableFuture> { +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/RequestCustomizer.java b/src/main/java/com/github/prominence/openweathermap/api/request/RequestCustomizer.java index 0768343..ccca335 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/RequestCustomizer.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/RequestCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -22,14 +22,11 @@ package com.github.prominence.openweathermap.api.request; -import com.github.prominence.openweathermap.api.enums.Accuracy; import com.github.prominence.openweathermap.api.enums.Language; import com.github.prominence.openweathermap.api.enums.UnitSystem; public interface RequestCustomizer> { - T accuracy(Accuracy accuracy); - T language(Language language); T unitSystem(UnitSystem unitSystem); diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/RequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/RequestTerminator.java index 95c6497..2060144 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/RequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/RequestTerminator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/RequestUrlBuilder.java b/src/main/java/com/github/prominence/openweathermap/api/request/RequestUrlBuilder.java index 068a691..aa9d55e 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/RequestUrlBuilder.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/RequestUrlBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -22,7 +22,6 @@ package com.github.prominence.openweathermap.api.request; -import com.github.prominence.openweathermap.api.enums.Accuracy; import com.github.prominence.openweathermap.api.enums.Language; import com.github.prominence.openweathermap.api.enums.UnitSystem; @@ -49,10 +48,7 @@ public class RequestUrlBuilder { requestParameters.put(key, value); } - public void applyCustomization(Accuracy accuracy, Language language, UnitSystem unitSystem) { - if (accuracy != null) { - addRequestParameter("type", accuracy.getValue()); - } + public void applyCustomization(Language language, UnitSystem unitSystem) { if (language != null) { addRequestParameter("lang", language.getValue()); } diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/ResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/ResponseMapper.java index 3ed73b6..f1ce9d8 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/ResponseMapper.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/ResponseMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastAsyncRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastAsyncRequestTerminator.java new file mode 100644 index 0000000..ee70295 --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastAsyncRequestTerminator.java @@ -0,0 +1,35 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.request.AsyncRequestTerminator; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + + +public interface FiveDayThreeHourStepForecastAsyncRequestTerminator extends AsyncRequestTerminator, String> { + + CompletableFuture asXML(); +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastAsyncRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastAsyncRequestTerminatorImpl.java new file mode 100644 index 0000000..aa926fe --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastAsyncRequestTerminatorImpl.java @@ -0,0 +1,62 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.enums.UnitSystem; +import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; +import com.github.prominence.openweathermap.api.utils.RequestUtils; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class FiveDayThreeHourStepForecastAsyncRequestTerminatorImpl implements FiveDayThreeHourStepForecastAsyncRequestTerminator { + + private final RequestUrlBuilder urlBuilder; + private final UnitSystem unitSystem; + + FiveDayThreeHourStepForecastAsyncRequestTerminatorImpl(RequestUrlBuilder urlBuilder, UnitSystem unitSystem) { + this.urlBuilder = urlBuilder; + this.unitSystem = unitSystem; + } + + @Override + public CompletableFuture> asJava() { + return CompletableFuture.supplyAsync(() -> new FiveDayThreeHourStepForecastResponseMapper(unitSystem).getTest()); + } + + @Override + public CompletableFuture asJSON() { + return CompletableFuture.supplyAsync(this::getRawResponse); + } + + @Override + public CompletableFuture asXML() { + urlBuilder.addRequestParameter("mode", "xml"); + return CompletableFuture.supplyAsync(this::getRawResponse); + } + + private String getRawResponse() { + return RequestUtils.getResponse(urlBuilder.buildUrl()); + } +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestCustomizer.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestCustomizer.java new file mode 100644 index 0000000..f8dde7e --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestCustomizer.java @@ -0,0 +1,34 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.request.RequestCustomizer; + +public interface FiveDayThreeHourStepForecastRequestCustomizer extends RequestCustomizer { + + FiveDayThreeHourStepForecastRequestCustomizer count(int numberOfTimestamps); + + FiveDayThreeHourStepForecastRequestTerminator retrieve(); + + FiveDayThreeHourStepForecastAsyncRequestTerminator retrieveAsync(); +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestCustomizerImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestCustomizerImpl.java new file mode 100644 index 0000000..13bd842 --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestCustomizerImpl.java @@ -0,0 +1,72 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.enums.Language; +import com.github.prominence.openweathermap.api.enums.UnitSystem; +import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; + +public class FiveDayThreeHourStepForecastRequestCustomizerImpl implements FiveDayThreeHourStepForecastRequestCustomizer { + + private final RequestUrlBuilder urlBuilder; + + private Language language; + private UnitSystem unitSystem; + private int count = -1; + + FiveDayThreeHourStepForecastRequestCustomizerImpl(RequestUrlBuilder urlBuilder) { + this.urlBuilder = urlBuilder; + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer language(Language language) { + this.language = language; + return this; + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer unitSystem(UnitSystem unitSystem) { + this.unitSystem = unitSystem; + return this; + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer count(int numberOfTimestamps) { + count = numberOfTimestamps; + return this; + } + + @Override + public FiveDayThreeHourStepForecastRequestTerminator retrieve() { + urlBuilder.applyCustomization(language, unitSystem); + urlBuilder.addRequestParameter("cnt", count); + return new FiveDayThreeHourStepForecastRequestTerminatorImpl(urlBuilder, unitSystem); + } + + @Override + public FiveDayThreeHourStepForecastAsyncRequestTerminator retrieveAsync() { + urlBuilder.applyCustomization(language, unitSystem); + urlBuilder.addRequestParameter("cnt", count); + return new FiveDayThreeHourStepForecastAsyncRequestTerminatorImpl(urlBuilder, unitSystem); + } +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestTerminator.java new file mode 100644 index 0000000..e80664b --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestTerminator.java @@ -0,0 +1,34 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.request.RequestTerminator; + +import java.util.List; + + +public interface FiveDayThreeHourStepForecastRequestTerminator extends RequestTerminator, String> { + + String asXML(); +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestTerminatorImpl.java new file mode 100644 index 0000000..9d61199 --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequestTerminatorImpl.java @@ -0,0 +1,61 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.enums.UnitSystem; +import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; +import com.github.prominence.openweathermap.api.utils.RequestUtils; + +import java.util.List; + +public class FiveDayThreeHourStepForecastRequestTerminatorImpl implements FiveDayThreeHourStepForecastRequestTerminator { + + private final RequestUrlBuilder urlBuilder; + private final UnitSystem unitSystem; + + FiveDayThreeHourStepForecastRequestTerminatorImpl(RequestUrlBuilder urlBuilder, UnitSystem unitSystem) { + this.urlBuilder = urlBuilder; + this.unitSystem = unitSystem; + } + + @Override + public List asJava() { + return new FiveDayThreeHourStepForecastResponseMapper(unitSystem).getTest(); + } + + @Override + public String asJSON() { + return getRawResponse(); + } + + @Override + public String asXML() { + urlBuilder.addRequestParameter("mode", "xml"); + return getRawResponse(); + } + + private String getRawResponse() { + return RequestUtils.getResponse(urlBuilder.buildUrl()); + } +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequester.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequester.java new file mode 100644 index 0000000..7c36de1 --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequester.java @@ -0,0 +1,40 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.model.Coordinate; + +public interface FiveDayThreeHourStepForecastRequester { + + FiveDayThreeHourStepForecastRequestCustomizer byCityName(String cityName); + + FiveDayThreeHourStepForecastRequestCustomizer byCityName(String cityName, String stateCode); + + FiveDayThreeHourStepForecastRequestCustomizer byCityName(String cityName, String stateCode, String countryCode); + + FiveDayThreeHourStepForecastRequestCustomizer byCityId(long cityId); + + FiveDayThreeHourStepForecastRequestCustomizer byCoordinate(Coordinate coordinate); + + FiveDayThreeHourStepForecastRequestCustomizer byZipCodeAndCountry(String zipCode, String countryCode); +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequesterImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequesterImpl.java new file mode 100644 index 0000000..2474b9b --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastRequesterImpl.java @@ -0,0 +1,73 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.model.Coordinate; +import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; + +public class FiveDayThreeHourStepForecastRequesterImpl implements FiveDayThreeHourStepForecastRequester { + + private final RequestUrlBuilder urlBuilder; + + public FiveDayThreeHourStepForecastRequesterImpl(String apiKey) { + urlBuilder = new RequestUrlBuilder(apiKey); + urlBuilder.append("forecast"); + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer byCityName(String cityName) { + urlBuilder.addRequestParameter("q", cityName); + return new FiveDayThreeHourStepForecastRequestCustomizerImpl(urlBuilder); + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer byCityName(String cityName, String stateCode) { + urlBuilder.addRequestParameter("q", cityName + "," + stateCode); + return new FiveDayThreeHourStepForecastRequestCustomizerImpl(urlBuilder); + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer byCityName(String cityName, String stateCode, String countryCode) { + urlBuilder.addRequestParameter("q", cityName + "," + stateCode + "," + countryCode); + return new FiveDayThreeHourStepForecastRequestCustomizerImpl(urlBuilder); + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer byCityId(long cityId) { + urlBuilder.addRequestParameter("id", cityId); + return new FiveDayThreeHourStepForecastRequestCustomizerImpl(urlBuilder); + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer byCoordinate(Coordinate coordinate) { + urlBuilder.addRequestParameter("lat", String.valueOf(coordinate.getLatitude())); + urlBuilder.addRequestParameter("lon", String.valueOf(coordinate.getLongitude())); + return new FiveDayThreeHourStepForecastRequestCustomizerImpl(urlBuilder); + } + + @Override + public FiveDayThreeHourStepForecastRequestCustomizer byZipCodeAndCountry(String zipCode, String countryCode) { + urlBuilder.addRequestParameter("zip", zipCode + "," + countryCode); + return new FiveDayThreeHourStepForecastRequestCustomizerImpl(urlBuilder); + } +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java new file mode 100644 index 0000000..f787c46 --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java @@ -0,0 +1,87 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.enums.UnitSystem; +import com.github.prominence.openweathermap.api.model.Weather; + +import java.util.List; + +/** + * Official API response documentation: + * Parameters: + * --- cod Internal parameter + * --- message Internal parameter + * --- cnt A number of timestamps returned in the API response + * --- list + * |- list.dt Time of data forecasted, unix, UTC + * |- list.main + * |- list.main.temp Temperature. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit. + * |- list.main.feels_like This temperature parameter accounts for the human perception of weather. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit. + * |- list.main.temp_min Minimum temperature at the moment of calculation. This is minimal forecasted temperature (within large megalopolises and urban areas), use this parameter optionally. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit. + * |- list.main.temp_max Maximum temperature at the moment of calculation. This is maximal forecasted temperature (within large megalopolises and urban areas), use this parameter optionally. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit. + * |- list.main.pressure Atmospheric pressure on the sea level by default, hPa + * |- list.main.sea_level Atmospheric pressure on the sea level, hPa + * |- list.main.grnd_level Atmospheric pressure on the ground level, hPa + * |- list.main.humidity Humidity, % + * |- list.main.temp_kf Internal par + * |- list.weather + * |- list.weather.id Weather condition id + * |- list.weather.main Group of weather parameters (Rain, Snow, Extreme etc.) + * |- list.weather.description Weather condition within the group. You can get the output in your language. + * |- list.weather.icon Weather icon id + * |- list.clouds + * |- list.clouds.all Cloudiness, % + * |- list.wind + * |- list.wind.speed Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour. + * |- list.wind.deg Wind direction, degrees (meteorological) + * |- list.visibility Average visibility, metres + * |- list.pop Probability of precipitation + * |- list.rain + * |- list.rain.3h Rain volume for last 3 hours, mm + * |- list.snow + * |- list.snow.3h Snow volume for last 3 hours + * |- list.sys + * |- list.sys.pod Part of the day (n - night, d - day) + * |- list.dt_txt Time of data forecasted, ISO, UTC + * --- city + * |- city.id City ID + * |- city.name City name + * |- city.coord + * |- city.coord.lat City geo location, latitude + * |- city.coord.lon City geo location, longitude + * |- city.country Country code (GB, JP etc.) + * |- city.timezone Shift in seconds from UTC + */ +public class FiveDayThreeHourStepForecastResponseMapper { + + private final UnitSystem unitSystem; + + public FiveDayThreeHourStepForecastResponseMapper(UnitSystem unitSystem) { + this.unitSystem = unitSystem; + } + + public List getTest() { + return null; + } +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequestTerminator.java index f9457fe..21c6bff 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequestTerminator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequester.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequester.java index 04169a9..702f5ea 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequester.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -22,12 +22,12 @@ package com.github.prominence.openweathermap.api.request.weather; -import com.github.prominence.openweathermap.api.request.weather.multiple.MultipleLocationsWeatherRequester; -import com.github.prominence.openweathermap.api.request.weather.single.SingleLocationWeatherRequester; +import com.github.prominence.openweathermap.api.request.weather.multiple.MultipleLocationsCurrentWeatherRequester; +import com.github.prominence.openweathermap.api.request.weather.single.SingleLocationCurrentWeatherRequester; public interface CurrentWeatherRequester { - SingleLocationWeatherRequester single(); + SingleLocationCurrentWeatherRequester single(); - MultipleLocationsWeatherRequester multiple(); + MultipleLocationsCurrentWeatherRequester multiple(); } diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequesterImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequesterImpl.java index 2c445ab..1585573 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequesterImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherRequesterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -24,9 +24,9 @@ package com.github.prominence.openweathermap.api.request.weather; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; import com.github.prominence.openweathermap.api.request.weather.multiple.MultipleLocationsCurrentWeatherRequesterImpl; -import com.github.prominence.openweathermap.api.request.weather.multiple.MultipleLocationsWeatherRequester; +import com.github.prominence.openweathermap.api.request.weather.multiple.MultipleLocationsCurrentWeatherRequester; import com.github.prominence.openweathermap.api.request.weather.single.SingleLocationCurrentWeatherRequesterImpl; -import com.github.prominence.openweathermap.api.request.weather.single.SingleLocationWeatherRequester; +import com.github.prominence.openweathermap.api.request.weather.single.SingleLocationCurrentWeatherRequester; public class CurrentWeatherRequesterImpl implements CurrentWeatherRequester { @@ -36,11 +36,11 @@ public class CurrentWeatherRequesterImpl implements CurrentWeatherRequester { urlBuilder = new RequestUrlBuilder(apiKey); } - public SingleLocationWeatherRequester single() { + public SingleLocationCurrentWeatherRequester single() { return new SingleLocationCurrentWeatherRequesterImpl(urlBuilder); } - public MultipleLocationsWeatherRequester multiple() { + public MultipleLocationsCurrentWeatherRequester multiple() { return new MultipleLocationsCurrentWeatherRequesterImpl(urlBuilder); } } diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java index a7c7275..d19a777 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsWeatherRequester.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsCurrentWeatherRequester.java similarity index 94% rename from src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsWeatherRequester.java rename to src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsCurrentWeatherRequester.java index 002a8df..a954564 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsWeatherRequester.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsCurrentWeatherRequester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.multiple; import com.github.prominence.openweathermap.api.model.Coordinate; import com.github.prominence.openweathermap.api.model.CoordinateRectangle; -public interface MultipleLocationsWeatherRequester { +public interface MultipleLocationsCurrentWeatherRequester { MultipleResultCurrentWeatherRequestCustomizer byRectangle(CoordinateRectangle rectangle, int zoom); diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsCurrentWeatherRequesterImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsCurrentWeatherRequesterImpl.java index c93f5ed..c2a8ea2 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsCurrentWeatherRequesterImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleLocationsCurrentWeatherRequesterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -26,7 +26,7 @@ import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; import com.github.prominence.openweathermap.api.model.Coordinate; import com.github.prominence.openweathermap.api.model.CoordinateRectangle; -public class MultipleLocationsCurrentWeatherRequesterImpl implements MultipleLocationsWeatherRequester { +public class MultipleLocationsCurrentWeatherRequesterImpl implements MultipleLocationsCurrentWeatherRequester { private final RequestUrlBuilder urlBuilder; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java index 13febcb..eb0e85a 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java index 25c1175..eb233d0 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizer.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizer.java index fc3552b..a5f667d 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizer.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizerImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizerImpl.java index a65eddd..5243608 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizerImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestCustomizerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -23,7 +23,6 @@ package com.github.prominence.openweathermap.api.request.weather.multiple; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; -import com.github.prominence.openweathermap.api.enums.Accuracy; import com.github.prominence.openweathermap.api.enums.Language; import com.github.prominence.openweathermap.api.enums.UnitSystem; @@ -31,7 +30,6 @@ public class MultipleResultCurrentWeatherRequestCustomizerImpl implements Multip private final RequestUrlBuilder urlBuilder; - private Accuracy accuracy; private Language language; private UnitSystem unitSystem; @@ -41,22 +39,16 @@ public class MultipleResultCurrentWeatherRequestCustomizerImpl implements Multip @Override public MultipleResultCurrentWeatherRequestTerminator retrieve() { - urlBuilder.applyCustomization(accuracy, language, unitSystem); + urlBuilder.applyCustomization(language, unitSystem); return new MultipleResultCurrentWeatherRequestTerminatorImpl(urlBuilder, unitSystem); } @Override public MultipleResultCurrentWeatherAsyncRequestTerminator retrieveAsync() { - urlBuilder.applyCustomization(accuracy, language, unitSystem); + urlBuilder.applyCustomization(language, unitSystem); return new MultipleResultCurrentWeatherAsyncRequestTerminatorImpl(urlBuilder, unitSystem); } - @Override - public MultipleResultCurrentWeatherRequestCustomizer accuracy(Accuracy accuracy) { - this.accuracy = accuracy; - return this; - } - @Override public MultipleResultCurrentWeatherRequestCustomizer language(Language language) { this.language = language; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java index ad0ae4e..cdd86df 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java index 9889a85..7bf4648 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationWeatherRequester.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationCurrentWeatherRequester.java similarity index 94% rename from src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationWeatherRequester.java rename to src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationCurrentWeatherRequester.java index 6812f25..83c8600 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationWeatherRequester.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationCurrentWeatherRequester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -24,7 +24,7 @@ package com.github.prominence.openweathermap.api.request.weather.single; import com.github.prominence.openweathermap.api.model.Coordinate; -public interface SingleLocationWeatherRequester { +public interface SingleLocationCurrentWeatherRequester { SingleResultCurrentWeatherRequestCustomizer byCityName(String cityName); diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationCurrentWeatherRequesterImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationCurrentWeatherRequesterImpl.java index 6c8bc14..acfcabf 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationCurrentWeatherRequesterImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleLocationCurrentWeatherRequesterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.single; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; import com.github.prominence.openweathermap.api.model.Coordinate; -public class SingleLocationCurrentWeatherRequesterImpl implements SingleLocationWeatherRequester { +public class SingleLocationCurrentWeatherRequesterImpl implements SingleLocationCurrentWeatherRequester { private final RequestUrlBuilder urlBuilder; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java index a44b1cc..2da33dc 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java index 7206820..1ff2cb1 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizer.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizer.java index 60ffe7a..1faf700 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizer.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizerImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizerImpl.java index 3fe71b8..c9c8acd 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizerImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestCustomizerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -23,7 +23,6 @@ package com.github.prominence.openweathermap.api.request.weather.single; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; -import com.github.prominence.openweathermap.api.enums.Accuracy; import com.github.prominence.openweathermap.api.enums.Language; import com.github.prominence.openweathermap.api.enums.UnitSystem; @@ -31,7 +30,6 @@ public class SingleResultCurrentWeatherRequestCustomizerImpl implements SingleRe private final RequestUrlBuilder urlBuilder; - private Accuracy accuracy; private Language language; private UnitSystem unitSystem; @@ -41,22 +39,16 @@ public class SingleResultCurrentWeatherRequestCustomizerImpl implements SingleRe @Override public SingleResultCurrentWeatherRequestTerminator retrieve() { - urlBuilder.applyCustomization(accuracy, language, unitSystem); + urlBuilder.applyCustomization(language, unitSystem); return new SingleResultCurrentWeatherRequestTerminatorImpl(urlBuilder, unitSystem); } @Override public SingleResultCurrentWeatherAsyncRequestTerminator retrieveAsync() { - urlBuilder.applyCustomization(accuracy, language, unitSystem); + urlBuilder.applyCustomization(language, unitSystem); return new SingleResultCurrentWeatherAsyncRequestTerminatorImpl(urlBuilder, unitSystem); } - @Override - public SingleResultCurrentWeatherRequestCustomizer accuracy(Accuracy accuracy) { - this.accuracy = accuracy; - return this; - } - @Override public SingleResultCurrentWeatherRequestCustomizer language(Language language) { this.language = language; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java index 5834cef..60e8f0d 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java index 9f5bc80..1ab380d 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java b/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java index 974bc21..40e5568 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java +++ b/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/test/java/com/github/prominence/openweathermap/api/ApiTest.java b/src/test/java/com/github/prominence/openweathermap/api/ApiTest.java index 767ee05..9f564d7 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/ApiTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/ApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 diff --git a/src/test/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastIntegrationTest.java b/src/test/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastIntegrationTest.java new file mode 100644 index 0000000..4db19af --- /dev/null +++ b/src/test/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastIntegrationTest.java @@ -0,0 +1,46 @@ +/* + * 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.forecast.free; + +import com.github.prominence.openweathermap.api.ApiTest; +import com.github.prominence.openweathermap.api.enums.Language; +import com.github.prominence.openweathermap.api.enums.UnitSystem; +import org.junit.Test; + +public class FiveDayThreeHourStepForecastIntegrationTest extends ApiTest { + + @Test + public void whenGetTest_thenReturnNotNull() { + final String weatherJSON = getClient() + .forecast5Day3HourStep() + .byCityName("Minsk") + .language(Language.RUSSIAN) + .unitSystem(UnitSystem.METRIC) + .count(15) + .retrieve() + .asJSON(); + + assert weatherJSON != null; + System.out.println(weatherJSON); + } +} diff --git a/src/test/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherIntegrationTest.java b/src/test/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherIntegrationTest.java deleted file mode 100644 index 24523a9..0000000 --- a/src/test/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherIntegrationTest.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2019 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.weather; - -import com.github.prominence.openweathermap.api.ApiTest; -import com.github.prominence.openweathermap.api.enums.Accuracy; -import com.github.prominence.openweathermap.api.enums.Language; -import com.github.prominence.openweathermap.api.enums.UnitSystem; -import com.github.prominence.openweathermap.api.exception.NoDataFoundException; -import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenException; -import com.github.prominence.openweathermap.api.OpenWeatherMapClient; -import com.github.prominence.openweathermap.api.model.Coordinate; -import com.github.prominence.openweathermap.api.model.CoordinateRectangle; -import com.github.prominence.openweathermap.api.model.Weather; -import org.junit.Test; - -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -public class CurrentWeatherIntegrationTest extends ApiTest { - - @Test - public void whenGetSingleCurrentWeatherByCoordinateRequestAsJava_thenReturnNotNull() { - final Weather weather = getClient() - .currentWeather() - .single() - .byCoordinate(new Coordinate(5, 5)) - .accuracy(Accuracy.ACCURATE) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asJava(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetSingleCurrentWeatherByCityIdRequestAsJava_thenReturnNotNull() { - final Weather weather = getClient() - .currentWeather() - .single() - .byCityId(350001514) - .language(Language.GERMAN) - .retrieve() - .asJava(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetSingleCurrentWeatherByCityNameRequestAsJava_thenReturnNotNull() { - final Weather weather = getClient() - .currentWeather() - .single() - .byCityName("Minsk") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asJava(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsJava_thenReturnNotNull() { - final Weather weather = getClient() - .currentWeather() - .single() - .byCityName("Moscow", "ru") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asJava(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetSingleCurrentWeatherByZipCodeAndCountryRequestAsJava_thenReturnNotNull() { - final Weather weather = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asJava(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetAnySingleCurrentRequestWeatherAsJson_thenReturnNotNull() { - final String weatherJson = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asJSON(); - - assert weatherJson != null; - System.out.println(weatherJson); - } - - @Test - public void whenGetAnySingleCurrentRequestWeatherAsXml_thenReturnNotNull() { - final String weatherXml = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asXML(); - - assert weatherXml != null; - System.out.println(weatherXml); - } - - @Test - public void whenGetAnySingleCurrentWeatherRequestAsHtml_thenReturnNotNull() { - final String weatherHtml = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asHTML(); - - assert weatherHtml != null; - System.out.println(weatherHtml); - } - - @Test - public void whenGetAnySingleCurrentWeatherAsyncRequestAsXml_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture weatherXmlFuture = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieveAsync() - .asXML(); - - assert weatherXmlFuture != null; - System.out.println(weatherXmlFuture.get()); - } - - @Test - public void whenGetAnySingleCurrentWeatherAsyncRequestAsJava_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture weatherFuture = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieveAsync() - .asJava(); - - assert weatherFuture != null; - System.out.println(weatherFuture.get()); - } - - @Test - public void whenGetAnySingleCurrentWeatherAsyncRequestAsJson_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture weatherFuture = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieveAsync() - .asJSON(); - - assert weatherFuture != null; - System.out.println(weatherFuture.get()); - } - - @Test - public void whenGetAnySingleCurrentWeatherAsyncRequestAsHtml_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture weatherFuture = getClient() - .currentWeather() - .single() - .byZipCodeAndCountry("220015", "by") - .language(Language.RUSSIAN) - .unitSystem(UnitSystem.METRIC) - .retrieveAsync() - .asHTML(); - - assert weatherFuture != null; - System.out.println(weatherFuture.get()); - } - - @Test - public void whenGetMultipleCurrentWeatherByCoordinateRequestAsJava_thenReturnNotNull() { - final List weatherList = getClient() - .currentWeather() - .multiple() - .byRectangle(new CoordinateRectangle(12, 32, 15, 37), 10) - .accuracy(Accuracy.ACCURATE) - .language(Language.ROMANIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asJava(); - - assert weatherList != null; - assert weatherList.size() > 0; - System.out.println(weatherList); - } - - @Test - public void whenGetMultipleCurrentWeatherByCoordinateAndServerClusteringRequestAsJava_thenReturnNotNull() { - final List weatherList = getClient() - .currentWeather() - .multiple() - .byRectangle(new CoordinateRectangle(12, 32, 15, 37), 10, true) - .accuracy(Accuracy.ACCURATE) - .language(Language.ROMANIAN) - .unitSystem(UnitSystem.METRIC) - .retrieve() - .asJava(); - - assert weatherList != null; - assert weatherList.size() > 0; - System.out.println(weatherList); - } - - @Test - public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsJava_thenReturnNotNull() { - final List weatherList = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieve() - .asJava(); - - assert weatherList != null; - assert weatherList.size() > 0; - System.out.println(weatherList); - } - - @Test - public void whenGetMultipleCurrentWeatherByCitiesInCycleAndServerClusteringRequestAsJava_thenReturnNotNull() { - final List weatherList = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieve() - .asJava(); - - assert weatherList != null; - assert weatherList.size() > 0; - System.out.println(weatherList); - } - - @Test - public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsJson_thenReturnNotNull() { - final String weather = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieve() - .asJSON(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsXml_thenReturnNotNull() { - final String weather = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieve() - .asXML(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsHtml_thenReturnNotNull() { - final String weather = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieve() - .asHTML(); - - assert weather != null; - System.out.println(weather); - } - - @Test - public void whenGetMultipleCurrentWeatherByCoordinateAndServerClusteringAsyncRequestAsJava_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture> weatherListFuture = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieveAsync() - .asJava(); - - assert weatherListFuture != null; - List weatherList = weatherListFuture.get(); - assert weatherList.size() > 0; - System.out.println(weatherList); - } - - @Test - public void whenGetMultipleCurrentWeatherByCoordinateAndServerClusteringAsyncRequestAsXml_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture weatherFuture = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieveAsync() - .asXML(); - - assert weatherFuture != null; - System.out.println(weatherFuture.get()); - } - - @Test - public void whenGetMultipleCurrentWeatherByCoordinateAndServerClusteringAsyncRequestAsJson_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture weatherFuture = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieveAsync() - .asJSON(); - - assert weatherFuture != null; - System.out.println(weatherFuture.get()); - } - - @Test - public void whenGetMultipleCurrentWeatherByCoordinateAndServerClusteringAsyncRequestAsHtml_thenReturnNotNull() throws ExecutionException, InterruptedException { - final CompletableFuture weatherFuture = getClient() - .currentWeather() - .multiple() - .byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true) - .language(Language.GERMAN) - .unitSystem(UnitSystem.IMPERIAL) - .retrieveAsync() - .asHTML(); - - assert weatherFuture != null; - System.out.println(weatherFuture.get()); - } - - @Test(expected = InvalidAuthTokenException.class) - public void whenRequestCurrentWeatherWithInvalidApiKey_thenThrowAnException() { - OpenWeatherMapClient client = new OpenWeatherMapClient("invalidKey"); - client - .currentWeather() - .single() - .byCityName("London") - .retrieve() - .asJSON(); - } - - @Test(expected = NoDataFoundException.class) - public void whenRequestCurrentWeatherForInvalidLocation_thenThrowAnException() { - getClient() - .currentWeather() - .single() - .byCityName("InvalidCity") - .retrieve() - .asJava(); - } -} diff --git a/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/CurrentWeatherIntegrationTest.java b/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherIntegrationTest.java similarity index 97% rename from src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/CurrentWeatherIntegrationTest.java rename to src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherIntegrationTest.java index 2bf55e2..144fb80 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/CurrentWeatherIntegrationTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -23,7 +23,6 @@ package com.github.prominence.openweathermap.api.request.weather.multiple; import com.github.prominence.openweathermap.api.ApiTest; -import com.github.prominence.openweathermap.api.enums.Accuracy; import com.github.prominence.openweathermap.api.enums.Language; import com.github.prominence.openweathermap.api.enums.UnitSystem; import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenException; @@ -38,7 +37,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -public class CurrentWeatherIntegrationTest extends ApiTest { +public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest { @Test public void whenGetMultipleCurrentWeatherByCoordinateRequestAsJava_thenReturnNotNull() { @@ -46,7 +45,6 @@ public class CurrentWeatherIntegrationTest extends ApiTest { .currentWeather() .multiple() .byRectangle(new CoordinateRectangle(12, 32, 15, 37), 10) - .accuracy(Accuracy.ACCURATE) .language(Language.ROMANIAN) .unitSystem(UnitSystem.METRIC) .retrieve() @@ -63,7 +61,6 @@ public class CurrentWeatherIntegrationTest extends ApiTest { .currentWeather() .multiple() .byRectangle(new CoordinateRectangle(12, 32, 15, 37), 10, true) - .accuracy(Accuracy.ACCURATE) .language(Language.ROMANIAN) .unitSystem(UnitSystem.METRIC) .retrieve() diff --git a/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/CurrentWeatherIntegrationTest.java b/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherIntegrationTest.java similarity index 97% rename from src/test/java/com/github/prominence/openweathermap/api/request/weather/single/CurrentWeatherIntegrationTest.java rename to src/test/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherIntegrationTest.java index e73a47e..c6aa723 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/CurrentWeatherIntegrationTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Alexey Zinchenko + * 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 @@ -23,7 +23,6 @@ package com.github.prominence.openweathermap.api.request.weather.single; import com.github.prominence.openweathermap.api.ApiTest; -import com.github.prominence.openweathermap.api.enums.Accuracy; import com.github.prominence.openweathermap.api.enums.Language; import com.github.prominence.openweathermap.api.enums.UnitSystem; import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenException; @@ -36,7 +35,7 @@ import org.junit.Test; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -public class CurrentWeatherIntegrationTest extends ApiTest { +public class SingleResultCurrentWeatherIntegrationTest extends ApiTest { @Test public void whenGetSingleCurrentWeatherByCoordinateRequestAsJava_thenReturnNotNull() { @@ -44,7 +43,6 @@ public class CurrentWeatherIntegrationTest extends ApiTest { .currentWeather() .single() .byCoordinate(new Coordinate(5, 5)) - .accuracy(Accuracy.ACCURATE) .unitSystem(UnitSystem.METRIC) .retrieve() .asJava();