Skip to content

Commit

Permalink
Add wheelchair trip request option
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 14, 2023
1 parent fa0d5d6 commit 1681c20
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>org.opentripplanner</groupId>
<artifactId>otp-client</artifactId>
<name>otp-client</name>
<!-- Don't change this, it's override by an extension !-->
<!-- Don't change this, it's overridden by an extension !-->
<version>0.0.0</version>
<description>Java client for the OpenTripPlanner GraphQL API</description>
<url>https://github.com/opentripplanner/otp-java-client</url>
Expand Down Expand Up @@ -101,7 +101,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.27.2</version>
<version>2.40.0</version>
<configuration>
<!-- define a language-specific format -->
<java>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/opentripplanner/client/OtpApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public TripPlan plan(TripPlanParameters req) throws IOException {
req.time().toLocalDate().toString(),
req.time().toLocalTime().toString(),
req.searchDirection().isArriveBy(),
req.walkReluctance());
req.walkReluctance(),
req.wheelchair());

final var jsonNode = sendRequest(formattedQuery);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.opentripplanner.client.model;

import jakarta.annotation.Nullable;
import java.util.Optional;

public record FareProductUse(String id, FareProduct product) {

public record FareProduct(
String id,
String name,
Money price,
@Nullable FareProduct.RiderCategory riderCategory,
@Nullable FareProduct.FareMedium medium) {
Optional<RiderCategory> riderCategory,
Optional<FareProduct.FareMedium> medium) {

public record RiderCategory(String id, String name) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public record TripPlanParameters(
int numItineraries,
Set<RequestMode> modes,
SearchDirection searchDirection,
float walkReluctance) {
float walkReluctance,
boolean wheelchair) {

public TripPlanParameters {
Objects.requireNonNull(from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class TripPlanParametersBuilder {
private SearchDirection searchDirection = SearchDirection.DEPART_AT;
private float walkReluctance = 1.4f;
private int numItineraries = 5;
private boolean wheelchair = false;

public TripPlanParametersBuilder withFrom(Coordinate from) {
this.from = from;
Expand Down Expand Up @@ -58,8 +59,13 @@ public TripPlanParametersBuilder withNumberOfItineraries(int ni) {
return this;
}

public TripPlanParametersBuilder withWheelchair(boolean wheelchair) {
this.wheelchair = wheelchair;
return this;
}

public TripPlanParameters build() {
return new TripPlanParameters(
from, coordinate, time, numItineraries, modes, searchDirection, walkReluctance);
from, coordinate, time, numItineraries, modes, searchDirection, walkReluctance, wheelchair);
}
}
1 change: 1 addition & 0 deletions src/main/resources/queries/plan.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ query {
time: "%s"
arriveBy: %s
walkReluctance: %s
wheelchair: %s
) {
itineraries {
startTime
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/opentripplanner/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public void seattleFares() throws IOException {
assertNotNull(product.price());
assertNotNull(product.price().currency());
assertNotNull(product.price().amount());
assertNotNull(product.medium().id());
assertNotNull(product.medium().name());
assertNotNull(product.riderCategory().id());
assertNotNull(product.riderCategory().name());
assertNotNull(product.medium().get().id());
assertNotNull(product.medium().get().name());
assertNotNull(product.riderCategory().get().id());
assertNotNull(product.riderCategory().get().name());
}
}

0 comments on commit 1681c20

Please sign in to comment.