// Path: api-common/src/main/java/org/openweathermap/api/common/Coordinate.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Coordinate {
//     /**
//      * City geo location, longitude
//      */
//     @SerializedName("lon")
//     private String longitude;
// 
//     /**
//      * City geo location, latitude
//      */
//     @SerializedName("lat")
//     private String latitude;
// }
// 
// Path: api-query/src/main/java/org/openweathermap/api/query/AbstractQuery.java
// @Data
// public abstract class AbstractQuery implements Query {
// 
//     @SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal"}) /* We'd like to be able to override the base URL. */
//     private String baseUrl = BASE_URL;
//     private UnitFormat unitFormat;
//     private Language language;
// 
//     @Override
//     public String toStringRepresentation(String apiKey) {
//         StringBuilder stringBuilder = new StringBuilder(baseUrl);
//         stringBuilder.append(getSearchPath());
//         stringBuilder.append(QUESTION_MARK);
//         if (getLanguage() != null) {
//             stringBuilder.append("lang=").append(getLanguage().getStringRepresentation()).append(AND);
//         }
//         if (getUnitFormat() != null) {
//             stringBuilder.append("units=").append(getUnitFormat().getStringRepresentation()).append(AND);
//         }
//         stringBuilder.append(getRequestPart());
//         stringBuilder.append(AND).append("appid=").append(apiKey);
//         return stringBuilder.toString();
//     }
// 
//     protected abstract String getSearchPath();
// 
//     protected abstract String getRequestPart();
// }
// 
// Path: api-query/src/main/java/org/openweathermap/api/query/Cluster.java
// public enum Cluster {
//     YES("yes"), NO("no");
//     private final String stringRepresentation;
// 
//     Cluster(String stringRepresentation) {
//         this.stringRepresentation = stringRepresentation;
//     }
// 
//     public static Cluster fromStringRepresentation(String stringRepresentation) {
//         for (Cluster cluster : values()) {
//             if (cluster.stringRepresentation.equals(stringRepresentation)) {
//                 return cluster;
//             }
//         }
//         throw new IllegalArgumentException("No Cluster was found with value:" + stringRepresentation);
//     }
// 
//     public String getStringRepresentation() {
//         return stringRepresentation;
//     }
// }


import lombok.Data;
import lombok.EqualsAndHashCode;
import org.openweathermap.api.common.Coordinate;
import org.openweathermap.api.query.AbstractQuery;
import org.openweathermap.api.query.Cluster;
/*
 * Copyright 2021, Yurii Serhiichuk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.openweathermap.api.query.currentweather;



@EqualsAndHashCode(callSuper = true)
@Data
public class ByRectangleZone extends AbstractQuery implements CurrentWeatherMultipleLocationsQuery {
    private final Coordinate leftBottom;
    private final Coordinate rightTop;
    private Cluster cluster;

    public ByRectangleZone(Coordinate leftBottom, Coordinate rightTop) {
        this.leftBottom = leftBottom == null ? new Coordinate("", "") : leftBottom;
        this.rightTop = rightTop == null ? new Coordinate("", "") : rightTop;
    }

    @Override
    protected String getSearchPath() {
        return "/box/city";
    }

    @Override
    protected String getRequestPart() {
        StringBuilder stringBuilder = new StringBuilder("bbox=");
        stringBuilder.append(leftBottom.getLongitude()).append(',').append(leftBottom.getLatitude()).append(',');
        stringBuilder.append(rightTop.getLongitude()).append(',').append(rightTop.getLatitude());
        if (cluster != null) {
            stringBuilder.append(AND).append("cluster=").append(cluster.getStringRepresentation());
        }
// Path: api-common/src/main/java/org/openweathermap/api/common/Coordinate.java
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public class Coordinate {
//     /**
//      * City geo location, longitude
//      */
//     @SerializedName("lon")
//     private String longitude;
// 
//     /**
//      * City geo location, latitude
//      */
//     @SerializedName("lat")
//     private String latitude;
// }
// 
// Path: api-query/src/main/java/org/openweathermap/api/query/AbstractQuery.java
// @Data
// public abstract class AbstractQuery implements Query {
// 
//     @SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal"}) /* We'd like to be able to override the base URL. */
//     private String baseUrl = BASE_URL;
//     private UnitFormat unitFormat;
//     private Language language;
// 
//     @Override
//     public String toStringRepresentation(String apiKey) {
//         StringBuilder stringBuilder = new StringBuilder(baseUrl);
//         stringBuilder.append(getSearchPath());
//         stringBuilder.append(QUESTION_MARK);
//         if (getLanguage() != null) {
//             stringBuilder.append("lang=").append(getLanguage().getStringRepresentation()).append(AND);
//         }
//         if (getUnitFormat() != null) {
//             stringBuilder.append("units=").append(getUnitFormat().getStringRepresentation()).append(AND);
//         }
//         stringBuilder.append(getRequestPart());
//         stringBuilder.append(AND).append("appid=").append(apiKey);
//         return stringBuilder.toString();
//     }
// 
//     protected abstract String getSearchPath();
// 
//     protected abstract String getRequestPart();
// }
// 
// Path: api-query/src/main/java/org/openweathermap/api/query/Cluster.java
// public enum Cluster {
//     YES("yes"), NO("no");
//     private final String stringRepresentation;
// 
//     Cluster(String stringRepresentation) {
//         this.stringRepresentation = stringRepresentation;
//     }
// 
//     public static Cluster fromStringRepresentation(String stringRepresentation) {
//         for (Cluster cluster : values()) {
//             if (cluster.stringRepresentation.equals(stringRepresentation)) {
//                 return cluster;
//             }
//         }
//         throw new IllegalArgumentException("No Cluster was found with value:" + stringRepresentation);
//     }
// 
//     public String getStringRepresentation() {
//         return stringRepresentation;
//     }
// }


// Path: api-query/src/main/java/org/openweathermap/api/query/currentweather/ByRectangleZone.java
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.openweathermap.api.common.Coordinate;
import org.openweathermap.api.query.AbstractQuery;
import org.openweathermap.api.query.Cluster;

/*
 * Copyright 2021, Yurii Serhiichuk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.openweathermap.api.query.currentweather;



@EqualsAndHashCode(callSuper = true)
@Data
public class ByRectangleZone extends AbstractQuery implements CurrentWeatherMultipleLocationsQuery {
    private final Coordinate leftBottom;
    private final Coordinate rightTop;
    private Cluster cluster;

    public ByRectangleZone(Coordinate leftBottom, Coordinate rightTop) {
        this.leftBottom = leftBottom == null ? new Coordinate("", "") : leftBottom;
        this.rightTop = rightTop == null ? new Coordinate("", "") : rightTop;
    }

    @Override
    protected String getSearchPath() {
        return "/box/city";
    }

    @Override
    protected String getRequestPart() {
        StringBuilder stringBuilder = new StringBuilder("bbox=");
        stringBuilder.append(leftBottom.getLongitude()).append(',').append(leftBottom.getLatitude()).append(',');
        stringBuilder.append(rightTop.getLongitude()).append(',').append(rightTop.getLatitude());
        if (cluster != null) {
            stringBuilder.append(AND).append("cluster=").append(cluster.getStringRepresentation());
        }
        return stringBuilder.toString();