From ef53c11e913d91ada5b8240e901f2859b30f30b7 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 20 Dec 2022 14:01:22 +0200 Subject: [PATCH 01/15] add request types --- .../sdk/dto/requests/TimeMapFastRequest.java | 4 +++ .../requests/timemapfast/ArrivalSearches.java | 20 +++++++++++++++ .../dto/requests/timemapfast/ManyToOne.java | 25 +++++++++++++++++++ .../dto/requests/timemapfast/OneToMany.java | 25 +++++++++++++++++++ .../requests/timemapfast/Transportation.java | 21 ++++++++++++++++ .../CoarseGridLevelOfDetail.java | 12 +++++++++ .../timemapfast/levelofdetail/Level.java | 16 ++++++++++++ .../levelofdetail/LevelOfDetail.java | 16 ++++++++++++ .../levelofdetail/SimpleLevelOfDetail.java | 12 +++++++++ .../SimpleNumericLevelOfDetail.java | 12 +++++++++ .../timemapfast/transportation/Cycling.java | 7 ++++++ .../transportation/CyclingAndFerry.java | 7 ++++++ .../timemapfast/transportation/Driving.java | 7 ++++++ .../transportation/DrivingAndFerry.java | 7 ++++++ .../DrivingAndPublicTransport.java | 8 ++++++ .../transportation/PublicTransport.java | 7 ++++++ .../timemapfast/transportation/Walking.java | 7 ++++++ .../transportation/WalkingAndFerry.java | 7 ++++++ .../dto/responses/TimeMapFastResponse.java | 4 +++ 19 files changed, 224 insertions(+) create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ArrivalSearches.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java new file mode 100644 index 0000000..86952f2 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java @@ -0,0 +1,4 @@ +package com.traveltime.sdk.dto.requests; + +public class TimeMapFastRequest { +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ArrivalSearches.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ArrivalSearches.java new file mode 100644 index 0000000..2f7625a --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ArrivalSearches.java @@ -0,0 +1,20 @@ +package com.traveltime.sdk.dto.requests.timemapfast; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +public class ArrivalSearches { + @NonNull + List manyToOne; + @NonNull + List oneToMany; +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java new file mode 100644 index 0000000..b0b4d9b --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java @@ -0,0 +1,25 @@ +package com.traveltime.sdk.dto.requests.timemapfast; + +import com.traveltime.sdk.dto.common.Coordinates; +import com.traveltime.sdk.dto.requests.timemapfast.levelofdetail.LevelOfDetail; +import lombok.*; +import lombok.extern.jackson.Jacksonized; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +public class ManyToOne { + @NonNull + String id; + @NonNull + Coordinates coords; + @NonNull + String arrivalTimePeriod; + @NonNull + Integer travelTime; + @NonNull + LevelOfDetail levelOfDetail; + @NonNull + Transportation transportation; +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java new file mode 100644 index 0000000..23cc4c5 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java @@ -0,0 +1,25 @@ +package com.traveltime.sdk.dto.requests.timemapfast; + +import com.traveltime.sdk.dto.common.Coordinates; +import com.traveltime.sdk.dto.requests.timemapfast.levelofdetail.LevelOfDetail; +import lombok.*; +import lombok.extern.jackson.Jacksonized; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +public class OneToMany { + @NonNull + String id; + @NonNull + Coordinates coords; + @NonNull + String arrivalTimePeriod; + @NonNull + Integer travelTime; + @NonNull + LevelOfDetail levelOfDetail; + @NonNull + Transportation transportation; +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java new file mode 100644 index 0000000..cbd9ae2 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java @@ -0,0 +1,21 @@ +package com.traveltime.sdk.dto.requests.timemapfast; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.traveltime.sdk.dto.requests.timefilterfast.transportation.*; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = PublicTransport.class, name = "public_transport"), + @JsonSubTypes.Type(value = Driving.class, name = "driving"), + @JsonSubTypes.Type(value = Cycling.class, name = "cycling"), + @JsonSubTypes.Type(value = Walking.class, name = "walking"), + @JsonSubTypes.Type(value = WalkingAndFerry.class, name = "walking+ferry"), + @JsonSubTypes.Type(value = CyclingAndFerry.class, name = "cycling+ferry"), + @JsonSubTypes.Type(value = DrivingAndFerry.class, name = "driving+ferry"), + @JsonSubTypes.Type(value = DrivingAndPublicTransport.class, name = "driving+public_transport"), +}) +public interface Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java new file mode 100644 index 0000000..1c9e99a --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java @@ -0,0 +1,12 @@ +package com.traveltime.sdk.dto.requests.timemapfast.levelofdetail; + +import lombok.AllArgsConstructor; +import lombok.NonNull; +import lombok.extern.jackson.Jacksonized; + +@Jacksonized +@AllArgsConstructor +public class CoarseGridLevelOfDetail implements LevelOfDetail { + @NonNull + Integer squareSize; +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java new file mode 100644 index 0000000..d93071e --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java @@ -0,0 +1,16 @@ +package com.traveltime.sdk.dto.requests.timemapfast.levelofdetail; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum Level { + @JsonProperty("lowest") + LOWEST, + @JsonProperty("low") + LOW, + @JsonProperty("medium") + MEDIUM, + @JsonProperty("high") + HIGH, + @JsonProperty("highest") + HIGHEST +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java new file mode 100644 index 0000000..9e2cc89 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java @@ -0,0 +1,16 @@ +package com.traveltime.sdk.dto.requests.timemapfast.levelofdetail; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "scaleType" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = SimpleNumericLevelOfDetail.class, name = "simple"), + @JsonSubTypes.Type(value = SimpleNumericLevelOfDetail.class, name = "simple_numeric"), + @JsonSubTypes.Type(value = CoarseGridLevelOfDetail.class, name = "coarse_grid"), +}) +public interface LevelOfDetail { +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java new file mode 100644 index 0000000..4ad4301 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java @@ -0,0 +1,12 @@ +package com.traveltime.sdk.dto.requests.timemapfast.levelofdetail; + +import lombok.AllArgsConstructor; +import lombok.NonNull; +import lombok.extern.jackson.Jacksonized; + +@Jacksonized +@AllArgsConstructor +public class SimpleLevelOfDetail implements LevelOfDetail { + @NonNull + Level level; +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java new file mode 100644 index 0000000..c4e33ac --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java @@ -0,0 +1,12 @@ +package com.traveltime.sdk.dto.requests.timemapfast.levelofdetail; + +import lombok.AllArgsConstructor; +import lombok.NonNull; +import lombok.extern.jackson.Jacksonized; + +@Jacksonized +@AllArgsConstructor +public class SimpleNumericLevelOfDetail implements LevelOfDetail { + @NonNull + Integer level; +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java new file mode 100644 index 0000000..603939e --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java @@ -0,0 +1,7 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class Cycling implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java new file mode 100644 index 0000000..cbc816a --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java @@ -0,0 +1,7 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class CyclingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java new file mode 100644 index 0000000..b793999 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java @@ -0,0 +1,7 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class Driving implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java new file mode 100644 index 0000000..84a22fb --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java @@ -0,0 +1,7 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class DrivingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java new file mode 100644 index 0000000..64a97b6 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java @@ -0,0 +1,8 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class DrivingAndPublicTransport implements Transportation { +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java new file mode 100644 index 0000000..5614010 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java @@ -0,0 +1,7 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class PublicTransport implements Transportation { } \ No newline at end of file diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java new file mode 100644 index 0000000..d0010de --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java @@ -0,0 +1,7 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class Walking implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java new file mode 100644 index 0000000..3daad06 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java @@ -0,0 +1,7 @@ +package com.traveltime.sdk.dto.requests.timemapfast.transportation; + +import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import lombok.Value; + +@Value +public class WalkingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java new file mode 100644 index 0000000..88291df --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java @@ -0,0 +1,4 @@ +package com.traveltime.sdk.dto.responses; + +public class TimeMapFastResponse { +} From 30f1e9cdd6891a6ca72f1bc5ba62e126bf34d75e Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 20 Dec 2022 16:12:01 +0200 Subject: [PATCH 02/15] add response --- .../{responses/timemap => common}/Shape.java | 7 ++-- .../sdk/dto/requests/TimeMapFastRequest.java | 36 ++++++++++++++++++- .../CoarseGridLevelOfDetail.java | 2 ++ .../SimpleNumericLevelOfDetail.java | 4 +++ .../dto/responses/TimeMapFastResponse.java | 15 ++++++++ .../sdk/dto/responses/timemap/Result.java | 1 + .../sdk/dto/responses/timemapfast/Result.java | 18 ++++++++++ 7 files changed, 79 insertions(+), 4 deletions(-) rename src/main/java/com/traveltime/sdk/dto/{responses/timemap => common}/Shape.java (63%) create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemap/Shape.java b/src/main/java/com/traveltime/sdk/dto/common/Shape.java similarity index 63% rename from src/main/java/com/traveltime/sdk/dto/responses/timemap/Shape.java rename to src/main/java/com/traveltime/sdk/dto/common/Shape.java index d2bb662..04648cb 100644 --- a/src/main/java/com/traveltime/sdk/dto/responses/timemap/Shape.java +++ b/src/main/java/com/traveltime/sdk/dto/common/Shape.java @@ -1,7 +1,8 @@ -package com.traveltime.sdk.dto.responses.timemap; +package com.traveltime.sdk.dto.common; -import com.traveltime.sdk.dto.common.Coordinates; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Value; import lombok.extern.jackson.Jacksonized; import java.util.List; diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java index 86952f2..ff19341 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java @@ -1,4 +1,38 @@ package com.traveltime.sdk.dto.requests; -public class TimeMapFastRequest { +import com.fasterxml.jackson.annotation.JsonInclude; +import com.traveltime.sdk.auth.TravelTimeCredentials; +import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; +import com.traveltime.sdk.dto.responses.TimeMapFastResponse; +import com.traveltime.sdk.dto.responses.errors.TravelTimeError; +import com.traveltime.sdk.utils.AcceptType; +import com.traveltime.sdk.utils.JsonUtils; +import io.vavr.control.Either; +import lombok.*; +import lombok.extern.jackson.Jacksonized; +import okhttp3.HttpUrl; +import okhttp3.Request; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TimeMapFastRequest extends TravelTimeRequest { + @NonNull + ArrivalSearches arrivalSearches; + + @Override + public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { + val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); + return JsonUtils + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_JSON)); + } + + @Override + public Class responseType() { + return TimeMapFastResponse.class; + } } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java index 1c9e99a..2875c04 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java @@ -1,5 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.levelofdetail; +import jakarta.validation.constraints.Min; import lombok.AllArgsConstructor; import lombok.NonNull; import lombok.extern.jackson.Jacksonized; @@ -8,5 +9,6 @@ @AllArgsConstructor public class CoarseGridLevelOfDetail implements LevelOfDetail { @NonNull + @Min(value = 600, message = "squareSize should be more than 600") Integer squareSize; } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java index c4e33ac..76adff0 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java @@ -1,5 +1,7 @@ package com.traveltime.sdk.dto.requests.timemapfast.levelofdetail; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; import lombok.AllArgsConstructor; import lombok.NonNull; import lombok.extern.jackson.Jacksonized; @@ -8,5 +10,7 @@ @AllArgsConstructor public class SimpleNumericLevelOfDetail implements LevelOfDetail { @NonNull + @Min(value = -20, message = "level should be between -20 and 2") + @Max(value = 2, message = "level should be between -20 and 2") Integer level; } diff --git a/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java index 88291df..ca1c916 100644 --- a/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java +++ b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastResponse.java @@ -1,4 +1,19 @@ package com.traveltime.sdk.dto.responses; +import com.traveltime.sdk.dto.responses.timemapfast.Result; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor public class TimeMapFastResponse { + @NonNull + List results; } diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemap/Result.java b/src/main/java/com/traveltime/sdk/dto/responses/timemap/Result.java index 2c7bb8d..add9564 100644 --- a/src/main/java/com/traveltime/sdk/dto/responses/timemap/Result.java +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemap/Result.java @@ -1,5 +1,6 @@ package com.traveltime.sdk.dto.responses.timemap; +import com.traveltime.sdk.dto.common.Shape; import lombok.*; import lombok.extern.jackson.Jacksonized; diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java new file mode 100644 index 0000000..b6a8dec --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java @@ -0,0 +1,18 @@ +package com.traveltime.sdk.dto.responses.timemapfast; + +import com.traveltime.sdk.dto.common.Shape; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +public class Result { + String searchId; + List shapes; +} From f2ff2a7fba20a0d498c480f5a40674ceef21b387 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Wed, 21 Dec 2022 12:33:18 +0200 Subject: [PATCH 03/15] update transportation interface --- .../sdk/dto/requests/timemapfast/transportation/Cycling.java | 2 +- .../requests/timemapfast/transportation/CyclingAndFerry.java | 2 +- .../sdk/dto/requests/timemapfast/transportation/Driving.java | 2 +- .../requests/timemapfast/transportation/DrivingAndFerry.java | 2 +- .../timemapfast/transportation/DrivingAndPublicTransport.java | 2 +- .../requests/timemapfast/transportation/PublicTransport.java | 2 +- .../sdk/dto/requests/timemapfast/transportation/Walking.java | 2 +- .../requests/timemapfast/transportation/WalkingAndFerry.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java index 603939e..213150c 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java index cbc816a..3540cb5 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java index b793999..da0af58 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java index 84a22fb..5886fc4 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java index 64a97b6..7406909 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java index 5614010..7f65c36 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java index d0010de..8b34807 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java index 3daad06..9ccd980 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java @@ -1,6 +1,6 @@ package com.traveltime.sdk.dto.requests.timemapfast.transportation; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; +import com.traveltime.sdk.dto.requests.timemapfast.Transportation; import lombok.Value; @Value From bceb065045b7b208570b5f836c719ba3baf96930 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Wed, 21 Dec 2022 16:25:48 +0200 Subject: [PATCH 04/15] - make LevelOfDetail optional - fix Transportation and LevelOfDetail interfaces --- .../com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java | 3 +-- .../com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java | 3 +-- .../sdk/dto/requests/timemapfast/Transportation.java | 2 +- .../timemapfast/levelofdetail/CoarseGridLevelOfDetail.java | 2 ++ .../dto/requests/timemapfast/levelofdetail/LevelOfDetail.java | 2 +- .../timemapfast/levelofdetail/SimpleLevelOfDetail.java | 2 ++ .../timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java | 2 ++ 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java index b0b4d9b..d061411 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java @@ -19,7 +19,6 @@ public class ManyToOne { @NonNull Integer travelTime; @NonNull - LevelOfDetail levelOfDetail; - @NonNull Transportation transportation; + LevelOfDetail levelOfDetail; } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java index 23cc4c5..3517cfd 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java @@ -19,7 +19,6 @@ public class OneToMany { @NonNull Integer travelTime; @NonNull - LevelOfDetail levelOfDetail; - @NonNull Transportation transportation; + LevelOfDetail levelOfDetail; } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java index cbd9ae2..1bb69b0 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.traveltime.sdk.dto.requests.timefilterfast.transportation.*; +import com.traveltime.sdk.dto.requests.timemapfast.transportation.*; @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java index 2875c04..09494b3 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java @@ -3,10 +3,12 @@ import jakarta.validation.constraints.Min; import lombok.AllArgsConstructor; import lombok.NonNull; +import lombok.Value; import lombok.extern.jackson.Jacksonized; @Jacksonized @AllArgsConstructor +@Value public class CoarseGridLevelOfDetail implements LevelOfDetail { @NonNull @Min(value = 600, message = "squareSize should be more than 600") diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java index 9e2cc89..0c4de46 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/LevelOfDetail.java @@ -8,7 +8,7 @@ property = "scaleType" ) @JsonSubTypes({ - @JsonSubTypes.Type(value = SimpleNumericLevelOfDetail.class, name = "simple"), + @JsonSubTypes.Type(value = SimpleLevelOfDetail.class, name = "simple"), @JsonSubTypes.Type(value = SimpleNumericLevelOfDetail.class, name = "simple_numeric"), @JsonSubTypes.Type(value = CoarseGridLevelOfDetail.class, name = "coarse_grid"), }) diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java index 4ad4301..cb2b8ee 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java @@ -2,10 +2,12 @@ import lombok.AllArgsConstructor; import lombok.NonNull; +import lombok.Value; import lombok.extern.jackson.Jacksonized; @Jacksonized @AllArgsConstructor +@Value public class SimpleLevelOfDetail implements LevelOfDetail { @NonNull Level level; diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java index 76adff0..0c00e18 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java @@ -4,10 +4,12 @@ import jakarta.validation.constraints.Min; import lombok.AllArgsConstructor; import lombok.NonNull; +import lombok.Value; import lombok.extern.jackson.Jacksonized; @Jacksonized @AllArgsConstructor +@Value public class SimpleNumericLevelOfDetail implements LevelOfDetail { @NonNull @Min(value = -20, message = "level should be between -20 and 2") From d1382ff154a7697356fb08f2a96854b16e787d15 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Wed, 21 Dec 2022 17:09:34 +0200 Subject: [PATCH 05/15] reuse transportationfast --- .../common/transportationfast/Cycling.java | 6 ++++++ .../transportationfast/CyclingAndFerry.java | 6 ++++++ .../common/transportationfast/Driving.java | 6 ++++++ .../transportationfast/DrivingAndFerry.java | 6 ++++++ .../DrivingAndPublicTransport.java | 3 +-- .../transportationfast/PublicTransport.java | 6 ++++++ .../transportationfast}/Transportation.java | 3 +-- .../common/transportationfast/Walking.java | 6 ++++++ .../transportationfast/WalkingAndFerry.java | 6 ++++++ .../requests/timefilterfast/ManyToOne.java | 1 + .../requests/timefilterfast/OneToMany.java | 1 + .../timefilterfast/Transportation.java | 21 ------------------- .../transportation/Cycling.java | 7 ------- .../transportation/CyclingAndFerry.java | 7 ------- .../transportation/Driving.java | 7 ------- .../transportation/DrivingAndFerry.java | 7 ------- .../transportation/PublicTransport.java | 7 ------- .../transportation/Walking.java | 7 ------- .../transportation/WalkingAndFerry.java | 7 ------- .../dto/requests/timemapfast/ManyToOne.java | 1 + .../dto/requests/timemapfast/OneToMany.java | 1 + .../timemapfast/transportation/Cycling.java | 7 ------- .../transportation/CyclingAndFerry.java | 7 ------- .../timemapfast/transportation/Driving.java | 7 ------- .../transportation/DrivingAndFerry.java | 7 ------- .../DrivingAndPublicTransport.java | 8 ------- .../transportation/PublicTransport.java | 7 ------- .../timemapfast/transportation/Walking.java | 7 ------- .../transportation/WalkingAndFerry.java | 7 ------- .../com/traveltime/sdk/TimeFilterTest.java | 2 +- 30 files changed, 49 insertions(+), 132 deletions(-) create mode 100644 src/main/java/com/traveltime/sdk/dto/common/transportationfast/Cycling.java create mode 100644 src/main/java/com/traveltime/sdk/dto/common/transportationfast/CyclingAndFerry.java create mode 100644 src/main/java/com/traveltime/sdk/dto/common/transportationfast/Driving.java create mode 100644 src/main/java/com/traveltime/sdk/dto/common/transportationfast/DrivingAndFerry.java rename src/main/java/com/traveltime/sdk/dto/{requests/timefilterfast/transportation => common/transportationfast}/DrivingAndPublicTransport.java (76%) create mode 100644 src/main/java/com/traveltime/sdk/dto/common/transportationfast/PublicTransport.java rename src/main/java/com/traveltime/sdk/dto/{requests/timemapfast => common/transportationfast}/Transportation.java (87%) create mode 100644 src/main/java/com/traveltime/sdk/dto/common/transportationfast/Walking.java create mode 100644 src/main/java/com/traveltime/sdk/dto/common/transportationfast/WalkingAndFerry.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/Transportation.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Cycling.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/CyclingAndFerry.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Driving.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/DrivingAndFerry.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/PublicTransport.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Walking.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/WalkingAndFerry.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java diff --git a/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Cycling.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Cycling.java new file mode 100644 index 0000000..ad77049 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Cycling.java @@ -0,0 +1,6 @@ +package com.traveltime.sdk.dto.common.transportationfast; + +import lombok.Value; + +@Value +public class Cycling implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/common/transportationfast/CyclingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/CyclingAndFerry.java new file mode 100644 index 0000000..e5b0c4e --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/CyclingAndFerry.java @@ -0,0 +1,6 @@ +package com.traveltime.sdk.dto.common.transportationfast; + +import lombok.Value; + +@Value +public class CyclingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Driving.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Driving.java new file mode 100644 index 0000000..cfcf3f9 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Driving.java @@ -0,0 +1,6 @@ +package com.traveltime.sdk.dto.common.transportationfast; + +import lombok.Value; + +@Value +public class Driving implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/common/transportationfast/DrivingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/DrivingAndFerry.java new file mode 100644 index 0000000..d62ed2f --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/DrivingAndFerry.java @@ -0,0 +1,6 @@ +package com.traveltime.sdk.dto.common.transportationfast; + +import lombok.Value; + +@Value +public class DrivingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/DrivingAndPublicTransport.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/DrivingAndPublicTransport.java similarity index 76% rename from src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/DrivingAndPublicTransport.java rename to src/main/java/com/traveltime/sdk/dto/common/transportationfast/DrivingAndPublicTransport.java index e5a8c65..1936fe9 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/DrivingAndPublicTransport.java +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/DrivingAndPublicTransport.java @@ -1,7 +1,6 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; +package com.traveltime.sdk.dto.common.transportationfast; import com.fasterxml.jackson.annotation.JsonInclude; -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; import jakarta.validation.constraints.Positive; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/traveltime/sdk/dto/common/transportationfast/PublicTransport.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/PublicTransport.java new file mode 100644 index 0000000..2fb39ed --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/PublicTransport.java @@ -0,0 +1,6 @@ +package com.traveltime.sdk.dto.common.transportationfast; + +import lombok.Value; + +@Value +public class PublicTransport implements Transportation { } \ No newline at end of file diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Transportation.java similarity index 87% rename from src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java rename to src/main/java/com/traveltime/sdk/dto/common/transportationfast/Transportation.java index 1bb69b0..169ff50 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/Transportation.java +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Transportation.java @@ -1,8 +1,7 @@ -package com.traveltime.sdk.dto.requests.timemapfast; +package com.traveltime.sdk.dto.common.transportationfast; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.traveltime.sdk.dto.requests.timemapfast.transportation.*; @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, diff --git a/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Walking.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Walking.java new file mode 100644 index 0000000..d554ead --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/Walking.java @@ -0,0 +1,6 @@ +package com.traveltime.sdk.dto.common.transportationfast; + +import lombok.Value; + +@Value +public class Walking implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/common/transportationfast/WalkingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/WalkingAndFerry.java new file mode 100644 index 0000000..6c2258b --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/common/transportationfast/WalkingAndFerry.java @@ -0,0 +1,6 @@ +package com.traveltime.sdk.dto.common.transportationfast; + +import lombok.Value; + +@Value +public class WalkingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/ManyToOne.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/ManyToOne.java index 529fe8b..de4f2cd 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/ManyToOne.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/ManyToOne.java @@ -1,6 +1,7 @@ package com.traveltime.sdk.dto.requests.timefilterfast; import com.traveltime.sdk.dto.common.Property; +import com.traveltime.sdk.dto.common.transportationfast.Transportation; import lombok.*; import lombok.extern.jackson.Jacksonized; diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/OneToMany.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/OneToMany.java index 630239a..b1d46e8 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/OneToMany.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/OneToMany.java @@ -1,6 +1,7 @@ package com.traveltime.sdk.dto.requests.timefilterfast; import com.traveltime.sdk.dto.common.Property; +import com.traveltime.sdk.dto.common.transportationfast.Transportation; import lombok.*; import lombok.extern.jackson.Jacksonized; diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/Transportation.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/Transportation.java deleted file mode 100644 index 1f1ff43..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/Transportation.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.traveltime.sdk.dto.requests.timefilterfast.transportation.*; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = PublicTransport.class, name = "public_transport"), - @JsonSubTypes.Type(value = Driving.class, name = "driving"), - @JsonSubTypes.Type(value = Cycling.class, name = "cycling"), - @JsonSubTypes.Type(value = Walking.class, name = "walking"), - @JsonSubTypes.Type(value = WalkingAndFerry.class, name = "walking+ferry"), - @JsonSubTypes.Type(value = CyclingAndFerry.class, name = "cycling+ferry"), - @JsonSubTypes.Type(value = DrivingAndFerry.class, name = "driving+ferry"), - @JsonSubTypes.Type(value = DrivingAndPublicTransport.class, name = "driving+public_transport"), -}) -public interface Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Cycling.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Cycling.java deleted file mode 100644 index d7b708e..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Cycling.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; - -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; -import lombok.Value; - -@Value -public class Cycling implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/CyclingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/CyclingAndFerry.java deleted file mode 100644 index c515ade..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/CyclingAndFerry.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; - -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; -import lombok.Value; - -@Value -public class CyclingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Driving.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Driving.java deleted file mode 100644 index 1f50132..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Driving.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; - -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; -import lombok.Value; - -@Value -public class Driving implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/DrivingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/DrivingAndFerry.java deleted file mode 100644 index ec97aac..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/DrivingAndFerry.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; - -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; -import lombok.Value; - -@Value -public class DrivingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/PublicTransport.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/PublicTransport.java deleted file mode 100644 index 04abf63..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/PublicTransport.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; - -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; -import lombok.Value; - -@Value -public class PublicTransport implements Transportation { } \ No newline at end of file diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Walking.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Walking.java deleted file mode 100644 index fec888c..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/Walking.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; - -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; -import lombok.Value; - -@Value -public class Walking implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/WalkingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/WalkingAndFerry.java deleted file mode 100644 index be67c6c..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timefilterfast/transportation/WalkingAndFerry.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timefilterfast.transportation; - -import com.traveltime.sdk.dto.requests.timefilterfast.Transportation; -import lombok.Value; - -@Value -public class WalkingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java index d061411..ccc82c2 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java @@ -1,6 +1,7 @@ package com.traveltime.sdk.dto.requests.timemapfast; import com.traveltime.sdk.dto.common.Coordinates; +import com.traveltime.sdk.dto.common.transportationfast.Transportation; import com.traveltime.sdk.dto.requests.timemapfast.levelofdetail.LevelOfDetail; import lombok.*; import lombok.extern.jackson.Jacksonized; diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java index 3517cfd..351132a 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java @@ -1,6 +1,7 @@ package com.traveltime.sdk.dto.requests.timemapfast; import com.traveltime.sdk.dto.common.Coordinates; +import com.traveltime.sdk.dto.common.transportationfast.Transportation; import com.traveltime.sdk.dto.requests.timemapfast.levelofdetail.LevelOfDetail; import lombok.*; import lombok.extern.jackson.Jacksonized; diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java deleted file mode 100644 index 213150c..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Cycling.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class Cycling implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java deleted file mode 100644 index 3540cb5..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/CyclingAndFerry.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class CyclingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java deleted file mode 100644 index da0af58..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Driving.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class Driving implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java deleted file mode 100644 index 5886fc4..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndFerry.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class DrivingAndFerry implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java deleted file mode 100644 index 7406909..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/DrivingAndPublicTransport.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class DrivingAndPublicTransport implements Transportation { -} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java deleted file mode 100644 index 7f65c36..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/PublicTransport.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class PublicTransport implements Transportation { } \ No newline at end of file diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java deleted file mode 100644 index 8b34807..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/Walking.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class Walking implements Transportation { } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java deleted file mode 100644 index 9ccd980..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/transportation/WalkingAndFerry.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.traveltime.sdk.dto.requests.timemapfast.transportation; - -import com.traveltime.sdk.dto.requests.timemapfast.Transportation; -import lombok.Value; - -@Value -public class WalkingAndFerry implements Transportation { } diff --git a/src/test/java/com/traveltime/sdk/TimeFilterTest.java b/src/test/java/com/traveltime/sdk/TimeFilterTest.java index b91124c..2e77bc3 100644 --- a/src/test/java/com/traveltime/sdk/TimeFilterTest.java +++ b/src/test/java/com/traveltime/sdk/TimeFilterTest.java @@ -6,13 +6,13 @@ import com.traveltime.sdk.dto.common.Location; import com.traveltime.sdk.dto.common.Property; import com.traveltime.sdk.dto.common.transportation.PublicTransport; +import com.traveltime.sdk.dto.common.transportationfast.DrivingAndPublicTransport; import com.traveltime.sdk.dto.requests.TimeFilterFastRequest; import com.traveltime.sdk.dto.requests.TimeFilterRequest; import com.traveltime.sdk.dto.requests.timefilter.*; import com.traveltime.sdk.dto.requests.timefilterfast.ArrivalSearches; import com.traveltime.sdk.dto.requests.timefilterfast.ManyToOne; import com.traveltime.sdk.dto.requests.timefilterfast.OneToMany; -import com.traveltime.sdk.dto.requests.timefilterfast.transportation.DrivingAndPublicTransport; import com.traveltime.sdk.dto.responses.*; import com.traveltime.sdk.dto.responses.errors.TravelTimeError; import io.vavr.control.Either; From e09286f38a00633648b3414c969d86f89e171ceb Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Thu, 22 Dec 2022 13:08:16 +0200 Subject: [PATCH 06/15] add additional request/response types --- .../dto/requests/TimeMapFastBoxesRequest.java | 39 +++++++++++++++ .../requests/TimeMapFastGeoJsonRequest.java | 38 +++++++++++++++ .../dto/requests/TimeMapFastWktRequest.java | 48 +++++++++++++++++++ .../responses/TimeMapFastBoxesResponse.java | 19 ++++++++ .../responses/TimeMapFastGeoJsonResponse.java | 14 ++++++ .../dto/responses/TimeMapFastWktResponse.java | 19 ++++++++ .../responses/timemapfast/BoxesResult.java | 19 ++++++++ .../timemapfast/ResponseProperties.java | 16 +++++++ .../sdk/dto/responses/timemapfast/Result.java | 2 + .../dto/responses/timemapfast/WktResult.java | 16 +++++++ 10 files changed, 230 insertions(+) create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastBoxesResponse.java create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastGeoJsonResponse.java create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastWktResponse.java create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/timemapfast/ResponseProperties.java create mode 100644 src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java new file mode 100644 index 0000000..4f73162 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java @@ -0,0 +1,39 @@ +package com.traveltime.sdk.dto.requests; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.traveltime.sdk.auth.TravelTimeCredentials; +import com.traveltime.sdk.dto.requests.timefilterfast.ArrivalSearches; +import com.traveltime.sdk.dto.responses.TimeMapFastBoxesResponse; +import com.traveltime.sdk.dto.responses.errors.TravelTimeError; +import com.traveltime.sdk.utils.AcceptType; +import com.traveltime.sdk.utils.JsonUtils; +import io.vavr.control.Either; +import lombok.*; +import lombok.extern.jackson.Jacksonized; +import okhttp3.HttpUrl; +import okhttp3.Request; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TimeMapFastBoxesRequest extends TravelTimeRequest { + @NonNull + ArrivalSearches arrivalSearches; + + @Override + public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { + val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); + AcceptType acceptType = AcceptType.APPLICATION_BOUNDING_BOXES_JSON; + return JsonUtils + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, acceptType)); + } + + @Override + public Class responseType() { + return TimeMapFastBoxesResponse.class; + } +} diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java new file mode 100644 index 0000000..ba1e376 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java @@ -0,0 +1,38 @@ +package com.traveltime.sdk.dto.requests; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.traveltime.sdk.auth.TravelTimeCredentials; +import com.traveltime.sdk.dto.requests.timefilterfast.ArrivalSearches; +import com.traveltime.sdk.dto.responses.TimeMapFastGeoJsonResponse; +import com.traveltime.sdk.dto.responses.errors.TravelTimeError; +import com.traveltime.sdk.utils.AcceptType; +import com.traveltime.sdk.utils.JsonUtils; +import io.vavr.control.Either; +import lombok.*; +import lombok.extern.jackson.Jacksonized; +import okhttp3.HttpUrl; +import okhttp3.Request; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TimeMapFastGeoJsonRequest extends TravelTimeRequest { + @NonNull + ArrivalSearches arrivalSearches; + + @Override + public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { + val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); + return JsonUtils + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_GEO_JSON)); + } + + @Override + public Class responseType() { + return TimeMapFastGeoJsonResponse.class; + } +} \ No newline at end of file diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java new file mode 100644 index 0000000..3125205 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java @@ -0,0 +1,48 @@ +package com.traveltime.sdk.dto.requests; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.traveltime.sdk.auth.TravelTimeCredentials; +import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; +import com.traveltime.sdk.dto.responses.TimeMapFastWktResponse; +import com.traveltime.sdk.dto.responses.errors.TravelTimeError; +import com.traveltime.sdk.utils.AcceptType; +import com.traveltime.sdk.utils.JsonUtils; +import io.vavr.control.Either; +import lombok.*; +import lombok.extern.jackson.Jacksonized; +import okhttp3.HttpUrl; +import okhttp3.Request; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TimeMapFastWktRequest extends TravelTimeRequest { + @NonNull + ArrivalSearches arrivalSearches; + @Builder.Default + boolean withHoles = true; + + private AcceptType acceptType() { + if (withHoles) { + return AcceptType.APPLICATION_WKT_JSON; + } else { + return AcceptType.APPLICATION_WKT_NO_HOLES_JSON; + } + } + + @Override + public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { + val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); + return JsonUtils + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, acceptType())); + } + + @Override + public Class responseType() { + return TimeMapFastWktResponse.class; + } +} diff --git a/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastBoxesResponse.java b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastBoxesResponse.java new file mode 100644 index 0000000..026283d --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastBoxesResponse.java @@ -0,0 +1,19 @@ +package com.traveltime.sdk.dto.responses; + +import com.traveltime.sdk.dto.responses.timemapfast.BoxesResult; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +public class TimeMapFastBoxesResponse { + @NonNull + List results; +} diff --git a/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastGeoJsonResponse.java b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastGeoJsonResponse.java new file mode 100644 index 0000000..0b84268 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastGeoJsonResponse.java @@ -0,0 +1,14 @@ +package com.traveltime.sdk.dto.responses; + +import com.traveltime.sdk.dto.geojson.FeatureCollection; +import com.traveltime.sdk.dto.responses.timemapfast.ResponseProperties; +import lombok.EqualsAndHashCode; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.geojson.MultiPolygon; + +@SuperBuilder +@EqualsAndHashCode(callSuper = true) +@Jacksonized +public class TimeMapFastGeoJsonResponse extends FeatureCollection { +} diff --git a/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastWktResponse.java b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastWktResponse.java new file mode 100644 index 0000000..5a21f81 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/TimeMapFastWktResponse.java @@ -0,0 +1,19 @@ +package com.traveltime.sdk.dto.responses; + +import com.traveltime.sdk.dto.responses.timemapfast.WktResult; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +public class TimeMapFastWktResponse { + @NonNull + List results; +} diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java new file mode 100644 index 0000000..ad8c37e --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java @@ -0,0 +1,19 @@ +package com.traveltime.sdk.dto.responses.timemapfast; + +import com.traveltime.sdk.dto.responses.timemap.BoundingBox; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +@Value +@Builder +@Jacksonized +public class BoxesResult { + @NonNull + String searchId; + @NonNull + List boundingBoxes; +} diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/ResponseProperties.java b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/ResponseProperties.java new file mode 100644 index 0000000..deb93c2 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/ResponseProperties.java @@ -0,0 +1,16 @@ +package com.traveltime.sdk.dto.responses.timemapfast; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ResponseProperties { + +} diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java index b6a8dec..de2f8c4 100644 --- a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/Result.java @@ -1,5 +1,6 @@ package com.traveltime.sdk.dto.responses.timemapfast; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.traveltime.sdk.dto.common.Shape; import lombok.AllArgsConstructor; import lombok.Builder; @@ -12,6 +13,7 @@ @Builder @Jacksonized @AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) public class Result { String searchId; List shapes; diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java new file mode 100644 index 0000000..db725f7 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java @@ -0,0 +1,16 @@ +package com.traveltime.sdk.dto.responses.timemapfast; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; +import org.locationtech.jts.geom.Geometry; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +public class WktResult { + String searchId; + Geometry shape; +} From 12df6fc08d24dc9cbe2edb1ed805700d99805190 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 27 Dec 2022 21:07:56 +0200 Subject: [PATCH 07/15] update boxes and geojson imports --- .../traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java | 2 +- .../traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java index 4f73162..2176e2b 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.traveltime.sdk.auth.TravelTimeCredentials; -import com.traveltime.sdk.dto.requests.timefilterfast.ArrivalSearches; +import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; import com.traveltime.sdk.dto.responses.TimeMapFastBoxesResponse; import com.traveltime.sdk.dto.responses.errors.TravelTimeError; import com.traveltime.sdk.utils.AcceptType; diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java index ba1e376..8fc80c9 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.traveltime.sdk.auth.TravelTimeCredentials; -import com.traveltime.sdk.dto.requests.timefilterfast.ArrivalSearches; +import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; import com.traveltime.sdk.dto.responses.TimeMapFastGeoJsonResponse; import com.traveltime.sdk.dto.responses.errors.TravelTimeError; import com.traveltime.sdk.utils.AcceptType; From b67ee1e421e9ed85dd1fc50303eb4b2c054be553 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 27 Dec 2022 21:17:24 +0200 Subject: [PATCH 08/15] add TimeMapFastKmlRequest --- .../dto/requests/TimeMapFastKmlRequest.java | 38 +++++++++++++++++++ .../responses/timemapfast/BoxesResult.java | 2 + .../dto/responses/timemapfast/WktResult.java | 2 + 3 files changed, 42 insertions(+) create mode 100644 src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java new file mode 100644 index 0000000..7e40b22 --- /dev/null +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java @@ -0,0 +1,38 @@ +package com.traveltime.sdk.dto.requests; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.traveltime.sdk.auth.TravelTimeCredentials; +import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; +import com.traveltime.sdk.dto.responses.errors.TravelTimeError; +import com.traveltime.sdk.utils.AcceptType; +import com.traveltime.sdk.utils.JsonUtils; +import de.micromata.opengis.kml.v_2_2_0.Kml; +import io.vavr.control.Either; +import lombok.*; +import lombok.extern.jackson.Jacksonized; +import okhttp3.HttpUrl; +import okhttp3.Request; + +@Value +@Builder +@Jacksonized +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TimeMapFastKmlRequest extends TravelTimeRequest{ + @NonNull + ArrivalSearches arrivalSearches; + + @Override + public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { + val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); + return JsonUtils + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_KML)); + } + + @Override + public Class responseType() { + return Kml.class; + } +} diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java index ad8c37e..a7ded68 100644 --- a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/BoxesResult.java @@ -1,5 +1,6 @@ package com.traveltime.sdk.dto.responses.timemapfast; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.traveltime.sdk.dto.responses.timemap.BoundingBox; import lombok.Builder; import lombok.NonNull; @@ -11,6 +12,7 @@ @Value @Builder @Jacksonized +@JsonIgnoreProperties(ignoreUnknown = true) public class BoxesResult { @NonNull String searchId; diff --git a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java index db725f7..8d03ce7 100644 --- a/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java +++ b/src/main/java/com/traveltime/sdk/dto/responses/timemapfast/WktResult.java @@ -1,5 +1,6 @@ package com.traveltime.sdk.dto.responses.timemapfast; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Value; @@ -10,6 +11,7 @@ @Builder @Jacksonized @AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) public class WktResult { String searchId; Geometry shape; From 47c90000b71209292668f00d36dbc00d8a088d76 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 27 Dec 2022 21:19:33 +0200 Subject: [PATCH 09/15] remove unsupported TimeMapFastKmlRequest --- .../dto/requests/TimeMapFastKmlRequest.java | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java deleted file mode 100644 index 7e40b22..0000000 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastKmlRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.traveltime.sdk.dto.requests; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.traveltime.sdk.auth.TravelTimeCredentials; -import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; -import com.traveltime.sdk.dto.responses.errors.TravelTimeError; -import com.traveltime.sdk.utils.AcceptType; -import com.traveltime.sdk.utils.JsonUtils; -import de.micromata.opengis.kml.v_2_2_0.Kml; -import io.vavr.control.Either; -import lombok.*; -import lombok.extern.jackson.Jacksonized; -import okhttp3.HttpUrl; -import okhttp3.Request; - -@Value -@Builder -@Jacksonized -@AllArgsConstructor -@EqualsAndHashCode(callSuper = true) -@JsonInclude(JsonInclude.Include.NON_NULL) -public class TimeMapFastKmlRequest extends TravelTimeRequest{ - @NonNull - ArrivalSearches arrivalSearches; - - @Override - public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { - val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); - return JsonUtils - .toJson(this) - .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_KML)); - } - - @Override - public Class responseType() { - return Kml.class; - } -} From 7e0e76004ee0f8f643a08cc57c7762ff1a0883c9 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 27 Dec 2022 21:22:46 +0200 Subject: [PATCH 10/15] update example --- .../main/java/com/traveltime/examples/TimeFilterExample.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/main/java/com/traveltime/examples/TimeFilterExample.java b/examples/src/main/java/com/traveltime/examples/TimeFilterExample.java index 5239785..52f45a5 100644 --- a/examples/src/main/java/com/traveltime/examples/TimeFilterExample.java +++ b/examples/src/main/java/com/traveltime/examples/TimeFilterExample.java @@ -5,9 +5,9 @@ import com.traveltime.sdk.dto.common.Coordinates; import com.traveltime.sdk.dto.common.Location; import com.traveltime.sdk.dto.common.Property; +import com.traveltime.sdk.dto.common.transportationfast.Driving; import com.traveltime.sdk.dto.requests.TimeFilterFastRequest; import com.traveltime.sdk.dto.requests.timefilterfast.ArrivalSearches; -import com.traveltime.sdk.dto.requests.timefilterfast.transportation.Driving; import com.traveltime.sdk.dto.requests.timefilterfast.OneToMany; import lombok.val; From 11e974574e1b6ffd0dbfe14cf1eaec29152498b4 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 27 Dec 2022 21:40:47 +0200 Subject: [PATCH 11/15] add TimeMapFastTest --- .../com/traveltime/sdk/TimeMapFastTest.java | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 src/test/java/com/traveltime/sdk/TimeMapFastTest.java diff --git a/src/test/java/com/traveltime/sdk/TimeMapFastTest.java b/src/test/java/com/traveltime/sdk/TimeMapFastTest.java new file mode 100644 index 0000000..92a0567 --- /dev/null +++ b/src/test/java/com/traveltime/sdk/TimeMapFastTest.java @@ -0,0 +1,120 @@ +package com.traveltime.sdk; + +import com.traveltime.sdk.auth.TravelTimeCredentials; +import com.traveltime.sdk.dto.common.Coordinates; +import com.traveltime.sdk.dto.common.transportationfast.PublicTransport; +import com.traveltime.sdk.dto.common.transportationfast.Transportation; +import com.traveltime.sdk.dto.requests.TimeMapFastBoxesRequest; +import com.traveltime.sdk.dto.requests.TimeMapFastGeoJsonRequest; +import com.traveltime.sdk.dto.requests.TimeMapFastRequest; +import com.traveltime.sdk.dto.requests.TimeMapFastWktRequest; +import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; +import com.traveltime.sdk.dto.requests.timemapfast.OneToMany; + +import com.traveltime.sdk.dto.responses.TimeMapFastBoxesResponse; +import com.traveltime.sdk.dto.responses.TimeMapFastGeoJsonResponse; +import com.traveltime.sdk.dto.responses.TimeMapFastResponse; +import com.traveltime.sdk.dto.responses.TimeMapFastWktResponse; +import com.traveltime.sdk.dto.responses.errors.TravelTimeError; +import com.traveltime.sdk.utils.JsonUtils; +import io.vavr.control.Either; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.Collections; + +public class TimeMapFastTest { + TravelTimeSDK sdk; + + @Before + public void init() { + TravelTimeCredentials credentials = new TravelTimeCredentials( + System.getenv("APP_ID"), + System.getenv("API_KEY") + ); + sdk = new TravelTimeSDK(credentials); + } + + @Test + public void shouldSendTimeMapFastRequest() { + Coordinates coords = new Coordinates(51.507609,-0.128315); + Transportation transportation = new PublicTransport(); + + TimeMapFastRequest request = new TimeMapFastRequest( + createArrivalSearches(coords, transportation) + ); + + Either response = sdk.send(request); + Assert.assertTrue(response.isRight()); + } + + @Test + public void shouldReceiveValidJsonResponse() { + Coordinates coords = new Coordinates(51.507609,-0.128315); + Transportation transportation = new PublicTransport(); + + TimeMapFastRequest request = new TimeMapFastRequest( + createArrivalSearches(coords, transportation) + ); + + Either response = sdk.getJsonResponse(request); + Assert.assertTrue(JsonUtils.isJsonValid(response.get())); + Assert.assertTrue(response.isRight()); + } + + @Test + public void shouldSendTimeMapFastGeoJsonRequest() { + Coordinates coords = new Coordinates(51.507609,-0.128315); + Transportation transportation = new PublicTransport(); + + TimeMapFastGeoJsonRequest request = new TimeMapFastGeoJsonRequest( + createArrivalSearches(coords, transportation) + ); + + Either response = sdk.send(request); + Assert.assertTrue(response.isRight()); + } + + @Test + public void shouldSendTimeMapFastBoundingBoxRequest() { + Coordinates coords = new Coordinates(51.507609,-0.128315); + Transportation transportation = new PublicTransport(); + + TimeMapFastBoxesRequest request = new TimeMapFastBoxesRequest( + createArrivalSearches(coords, transportation) + ); + + Either response = sdk.send(request); + Assert.assertTrue(response.isRight()); + } + + @Test + public void shouldSendTimeMapFastWktRequest() { + Coordinates coords = new Coordinates(51.507609,-0.128315); + Transportation transportation = new PublicTransport(); + + TimeMapFastWktRequest request = new TimeMapFastWktRequest( + createArrivalSearches(coords, transportation), true + ); + + Either response = sdk.send(request); + Assert.assertTrue(response.isRight()); + } + + private ArrivalSearches createArrivalSearches(Coordinates coords, Transportation transportation) { + OneToMany oneToMany = OneToMany + .builder() + .id("Test arrival search fast") + .arrivalTimePeriod("weekday_morning") + .transportation(transportation) + .coords(coords) + .travelTime(900) + .build(); + + return ArrivalSearches + .builder() + .oneToMany(Collections.singletonList(oneToMany)) + .build(); + } +} From eb4d1115e97db806347f01c6709f18a1ab6e2d8f Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 3 Jan 2023 11:19:39 +0200 Subject: [PATCH 12/15] update test init function --- src/test/java/com/traveltime/sdk/TimeMapFastTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/traveltime/sdk/TimeMapFastTest.java b/src/test/java/com/traveltime/sdk/TimeMapFastTest.java index 92a0567..83c0d9f 100644 --- a/src/test/java/com/traveltime/sdk/TimeMapFastTest.java +++ b/src/test/java/com/traveltime/sdk/TimeMapFastTest.java @@ -115,6 +115,7 @@ private ArrivalSearches createArrivalSearches(Coordinates coords, Transportation return ArrivalSearches .builder() .oneToMany(Collections.singletonList(oneToMany)) + .manyToOne(Collections.emptyList()) .build(); } } From 2a0a5c579a28ddd48b0c309645e9f863d96185eb Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 3 Jan 2023 13:58:20 +0200 Subject: [PATCH 13/15] style fixes --- .../com/traveltime/sdk/TravelTimeSDK.java | 30 ++++++++----------- .../sdk/dto/requests/ProtoRequest.java | 1 - .../dto/requests/TimeMapFastBoxesRequest.java | 4 +-- .../requests/TimeMapFastGeoJsonRequest.java | 4 +-- .../sdk/dto/requests/TimeMapFastRequest.java | 4 +-- .../dto/requests/TimeMapFastWktRequest.java | 4 +-- .../dto/requests/timemapfast/ManyToOne.java | 5 +++- .../dto/requests/timemapfast/OneToMany.java | 5 +++- .../CoarseGridLevelOfDetail.java | 6 ++-- .../timemapfast/levelofdetail/Level.java | 20 ++++++------- .../levelofdetail/SimpleLevelOfDetail.java | 4 +-- .../SimpleNumericLevelOfDetail.java | 8 ++--- .../com/traveltime/sdk/TimeMapFastTest.java | 15 +++++----- 13 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/traveltime/sdk/TravelTimeSDK.java b/src/main/java/com/traveltime/sdk/TravelTimeSDK.java index 9c78077..355138e 100644 --- a/src/main/java/com/traveltime/sdk/TravelTimeSDK.java +++ b/src/main/java/com/traveltime/sdk/TravelTimeSDK.java @@ -72,29 +72,25 @@ private Either parseJsonBody(TravelTimeRequest reques } else { return JsonUtils .fromJson(body, ResponseError.class) - .flatMap(responseError -> Either.left(responseError)); + .flatMap(Either::left); } } private Either deserializeProtoResponse(ProtoRequest request, Response response) { String url = response.request().url().toString(); - switch(response.code()){ - case 404: { - RequestError error = new RequestError("Network response is 404 (Not found). Make sure URL " + - url + " is correct."); - return Either.left(error); - } - default: { - Either protoResponse = Try - .of(() -> Objects.requireNonNull(response.body()).bytes()) - .toEither() - .mapLeft(cause -> new IOError(cause, IO_CONNECTION_ERROR + cause.getMessage())) - .flatMap(request::parseBytes); - - response.close(); - return protoResponse; - } + if (response.code() == 404) { + RequestError error = new RequestError("Network response is 404 (Not found). Make sure URL " + + url + " is correct."); + return Either.left(error); } + Either protoResponse = Try + .of(() -> Objects.requireNonNull(response.body()).bytes()) + .toEither() + .mapLeft(cause -> new IOError(cause, IO_CONNECTION_ERROR + cause.getMessage())) + .flatMap(request::parseBytes); + + response.close(); + return protoResponse; } private Either getParsedResponse(TravelTimeRequest request, Response response) { diff --git a/src/main/java/com/traveltime/sdk/dto/requests/ProtoRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/ProtoRequest.java index 31ec6bb..26a20a7 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/ProtoRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/ProtoRequest.java @@ -12,7 +12,6 @@ import okhttp3.Request; import okhttp3.RequestBody; -import java.net.URI; import java.util.List; public abstract class ProtoRequest { diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java index 2176e2b..ec09a9b 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastBoxesRequest.java @@ -28,8 +28,8 @@ public Either createRequest(HttpUrl baseUri, TravelTim val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); AcceptType acceptType = AcceptType.APPLICATION_BOUNDING_BOXES_JSON; return JsonUtils - .toJson(this) - .map(json -> createPostRequest(credentials, uri, json, acceptType)); + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, acceptType)); } @Override diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java index 8fc80c9..0b53a3e 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastGeoJsonRequest.java @@ -27,8 +27,8 @@ public class TimeMapFastGeoJsonRequest extends TravelTimeRequest createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); return JsonUtils - .toJson(this) - .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_GEO_JSON)); + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_GEO_JSON)); } @Override diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java index ff19341..0894d00 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastRequest.java @@ -27,8 +27,8 @@ public class TimeMapFastRequest extends TravelTimeRequest { public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); return JsonUtils - .toJson(this) - .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_JSON)); + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, AcceptType.APPLICATION_JSON)); } @Override diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java index 3125205..3954213 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java @@ -37,8 +37,8 @@ private AcceptType acceptType() { public Either createRequest(HttpUrl baseUri, TravelTimeCredentials credentials) { val uri = baseUri.newBuilder().addPathSegments("time-map/fast").build(); return JsonUtils - .toJson(this) - .map(json -> createPostRequest(credentials, uri, json, acceptType())); + .toJson(this) + .map(json -> createPostRequest(credentials, uri, json, acceptType())); } @Override diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java index ccc82c2..f1d9ff4 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/ManyToOne.java @@ -3,7 +3,10 @@ import com.traveltime.sdk.dto.common.Coordinates; import com.traveltime.sdk.dto.common.transportationfast.Transportation; import com.traveltime.sdk.dto.requests.timemapfast.levelofdetail.LevelOfDetail; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; import lombok.extern.jackson.Jacksonized; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java index 351132a..69ae020 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/OneToMany.java @@ -3,7 +3,10 @@ import com.traveltime.sdk.dto.common.Coordinates; import com.traveltime.sdk.dto.common.transportationfast.Transportation; import com.traveltime.sdk.dto.requests.timemapfast.levelofdetail.LevelOfDetail; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; import lombok.extern.jackson.Jacksonized; @Value diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java index 09494b3..db07c2d 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/CoarseGridLevelOfDetail.java @@ -10,7 +10,7 @@ @AllArgsConstructor @Value public class CoarseGridLevelOfDetail implements LevelOfDetail { - @NonNull - @Min(value = 600, message = "squareSize should be more than 600") - Integer squareSize; + @NonNull + @Min(value = 600, message = "squareSize should be more than 600") + Integer squareSize; } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java index d93071e..54e94ec 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/Level.java @@ -3,14 +3,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum Level { - @JsonProperty("lowest") - LOWEST, - @JsonProperty("low") - LOW, - @JsonProperty("medium") - MEDIUM, - @JsonProperty("high") - HIGH, - @JsonProperty("highest") - HIGHEST + @JsonProperty("lowest") + LOWEST, + @JsonProperty("low") + LOW, + @JsonProperty("medium") + MEDIUM, + @JsonProperty("high") + HIGH, + @JsonProperty("highest") + HIGHEST } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java index cb2b8ee..493e7fa 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleLevelOfDetail.java @@ -9,6 +9,6 @@ @AllArgsConstructor @Value public class SimpleLevelOfDetail implements LevelOfDetail { - @NonNull - Level level; + @NonNull + Level level; } diff --git a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java index 0c00e18..f06da38 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/timemapfast/levelofdetail/SimpleNumericLevelOfDetail.java @@ -11,8 +11,8 @@ @AllArgsConstructor @Value public class SimpleNumericLevelOfDetail implements LevelOfDetail { - @NonNull - @Min(value = -20, message = "level should be between -20 and 2") - @Max(value = 2, message = "level should be between -20 and 2") - Integer level; + @NonNull + @Min(value = -20, message = "level should be between -20 and 2") + @Max(value = 2, message = "level should be between -20 and 2") + Integer level; } diff --git a/src/test/java/com/traveltime/sdk/TimeMapFastTest.java b/src/test/java/com/traveltime/sdk/TimeMapFastTest.java index 83c0d9f..f912d55 100644 --- a/src/test/java/com/traveltime/sdk/TimeMapFastTest.java +++ b/src/test/java/com/traveltime/sdk/TimeMapFastTest.java @@ -10,7 +10,6 @@ import com.traveltime.sdk.dto.requests.TimeMapFastWktRequest; import com.traveltime.sdk.dto.requests.timemapfast.ArrivalSearches; import com.traveltime.sdk.dto.requests.timemapfast.OneToMany; - import com.traveltime.sdk.dto.responses.TimeMapFastBoxesResponse; import com.traveltime.sdk.dto.responses.TimeMapFastGeoJsonResponse; import com.traveltime.sdk.dto.responses.TimeMapFastResponse; @@ -30,15 +29,15 @@ public class TimeMapFastTest { @Before public void init() { TravelTimeCredentials credentials = new TravelTimeCredentials( - System.getenv("APP_ID"), - System.getenv("API_KEY") + System.getenv("APP_ID"), + System.getenv("API_KEY") ); sdk = new TravelTimeSDK(credentials); } @Test public void shouldSendTimeMapFastRequest() { - Coordinates coords = new Coordinates(51.507609,-0.128315); + Coordinates coords = new Coordinates(51.507609, -0.128315); Transportation transportation = new PublicTransport(); TimeMapFastRequest request = new TimeMapFastRequest( @@ -51,7 +50,7 @@ public void shouldSendTimeMapFastRequest() { @Test public void shouldReceiveValidJsonResponse() { - Coordinates coords = new Coordinates(51.507609,-0.128315); + Coordinates coords = new Coordinates(51.507609, -0.128315); Transportation transportation = new PublicTransport(); TimeMapFastRequest request = new TimeMapFastRequest( @@ -65,7 +64,7 @@ public void shouldReceiveValidJsonResponse() { @Test public void shouldSendTimeMapFastGeoJsonRequest() { - Coordinates coords = new Coordinates(51.507609,-0.128315); + Coordinates coords = new Coordinates(51.507609, -0.128315); Transportation transportation = new PublicTransport(); TimeMapFastGeoJsonRequest request = new TimeMapFastGeoJsonRequest( @@ -78,7 +77,7 @@ public void shouldSendTimeMapFastGeoJsonRequest() { @Test public void shouldSendTimeMapFastBoundingBoxRequest() { - Coordinates coords = new Coordinates(51.507609,-0.128315); + Coordinates coords = new Coordinates(51.507609, -0.128315); Transportation transportation = new PublicTransport(); TimeMapFastBoxesRequest request = new TimeMapFastBoxesRequest( @@ -91,7 +90,7 @@ public void shouldSendTimeMapFastBoundingBoxRequest() { @Test public void shouldSendTimeMapFastWktRequest() { - Coordinates coords = new Coordinates(51.507609,-0.128315); + Coordinates coords = new Coordinates(51.507609, -0.128315); Transportation transportation = new PublicTransport(); TimeMapFastWktRequest request = new TimeMapFastWktRequest( From 6da95e6da38f5f7b6f910f40a0f3bab061a1a3f9 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 3 Jan 2023 14:00:26 +0200 Subject: [PATCH 14/15] use ternary operator to select wkt type --- .../traveltime/sdk/dto/requests/TimeMapFastWktRequest.java | 6 +----- .../com/traveltime/sdk/dto/requests/TimeMapWktRequest.java | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java index 3954213..bf53dc7 100644 --- a/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java +++ b/src/main/java/com/traveltime/sdk/dto/requests/TimeMapFastWktRequest.java @@ -26,11 +26,7 @@ public class TimeMapFastWktRequest extends TravelTimeRequest { boolean withHoles = true; public AcceptType acceptType() { - if (withHoles) { - return AcceptType.APPLICATION_WKT_JSON; - } else { - return AcceptType.APPLICATION_WKT_NO_HOLES_JSON; - } + return withHoles ? AcceptType.APPLICATION_WKT_JSON : AcceptType.APPLICATION_WKT_NO_HOLES_JSON; } @Override From ce2c42a6babf83e16e75fae8ac24532623f8ffa4 Mon Sep 17 00:00:00 2001 From: EivydasKoc Date: Tue, 3 Jan 2023 14:15:46 +0200 Subject: [PATCH 15/15] revert to lambda --- src/main/java/com/traveltime/sdk/TravelTimeSDK.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/traveltime/sdk/TravelTimeSDK.java b/src/main/java/com/traveltime/sdk/TravelTimeSDK.java index 355138e..83ac41c 100644 --- a/src/main/java/com/traveltime/sdk/TravelTimeSDK.java +++ b/src/main/java/com/traveltime/sdk/TravelTimeSDK.java @@ -72,7 +72,7 @@ private Either parseJsonBody(TravelTimeRequest reques } else { return JsonUtils .fromJson(body, ResponseError.class) - .flatMap(Either::left); + .flatMap(responseError -> Either.left(responseError)); } }