Skip to content

Commit 24ce7b2

Browse files
committed
add etc2
1 parent ca820fb commit 24ce7b2

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Mapbox welcomes participation and contributions from everyone.
44

55
### main
66

7+
- Added `DirectionsCriteria#PAYMENT_METHOD_ETC2` option to pass as `RouteOptions#computeTollCosts` and to receive in `IntersectionsLanes#paymentMethods`.
8+
79
### v6.14.0 - October 26, 2023
810

911
- Added `LegAnnotation#freeflowSpeed` and `LegAnnotation#currentSpeed`. To receive these annotations, pass `DirectionsCriteria.ANNOTATION_FREEFLOW_SPEED` and `DirectionsCriteria.ANNOTATION_CURRENT_SPEED` in the request in the "annotations" parameter.

services-directions-models/src/main/java/com/mapbox/api/directions/v5/DirectionsCriteria.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,15 @@ public final class DirectionsCriteria {
338338
@SuppressWarnings("checkstyle:javadocvariable")
339339
public static final String PAYMENT_METHOD_ETC = "etc";
340340

341+
/*
342+
* A ETC 2.0 transponder.
343+
* NOTE: If the specified `payment_methods` parameter includes `etc2`,
344+
* `etc` lane will be validated and activated.
345+
* This is because ETC2 user can pass through ETC tollbooths.
346+
*/
347+
@SuppressWarnings("checkstyle:javadocvariable")
348+
public static final String PAYMENT_METHOD_ETC2 = "etc2";
349+
341350
/*
342351
* A transponder only used for several specific roads in Japan.
343352
*/
@@ -668,6 +677,7 @@ private DirectionsCriteria() {
668677
PAYMENT_METHOD_VIDEO,
669678
PAYMENT_METHOD_CRYPTOCURRENCIES,
670679
PAYMENT_METHOD_APP,
680+
PAYMENT_METHOD_ETC2,
671681
})
672682
public @interface PaymentMethodsCriteria {
673683
}

services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/IntersectionLanesTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,18 @@ public void testFromJson_etcAndGeneralPayment() {
8888

8989
assertEquals(intersectionLanes, intersectionLanesFromJson);
9090
}
91+
92+
@Test
93+
public void testFromJson_etc2Payment() {
94+
IntersectionLanes intersectionLanes = IntersectionLanes.builder()
95+
.paymentMethods(Arrays.asList(
96+
DirectionsCriteria.PAYMENT_METHOD_ETC2
97+
))
98+
.build();
99+
100+
String jsonString = "{\"payment_methods\": [\"etc2\"]}";
101+
IntersectionLanes intersectionLanesFromJson = IntersectionLanes.fromJson(jsonString);
102+
103+
assertEquals(intersectionLanes, intersectionLanesFromJson);
104+
}
91105
}

services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/RouteOptionsTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,17 @@ public void etcPaymentMethod() {
10371037
assertContains(query, "payment_methods=etc");
10381038
}
10391039

1040+
@Test
1041+
public void etc2PaymentMethod() {
1042+
RouteOptions routeOptions = routeOptions().toBuilder()
1043+
.paymentMethodsList(Arrays.asList(DirectionsCriteria.PAYMENT_METHOD_ETC2))
1044+
.build();
1045+
String query = routeOptions.toUrl("test").getQuery();
1046+
1047+
assertEquals("etc2", routeOptions.paymentMethods());
1048+
assertContains(query, "payment_methods=etc2");
1049+
}
1050+
10401051
@Test
10411052
public void generalAndEtcPaymentsMethod() {
10421053
List<String> paymentMethods = Arrays.asList(

0 commit comments

Comments
 (0)