Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ private static List<V6RequestOptions> requestOptions() {
.street("Pennsylvania Avenue NW")
.postcode("20500")
.place("Washington, DC")
.country("us")
.build();

final V6ForwardGeocodingRequestOptions structuredInputOptions = V6ForwardGeocodingRequestOptions
.builder(structuredInputQuery)
.country("us")
.build();

final V6ReverseGeocodingRequestOptions reverseOptions = V6ReverseGeocodingRequestOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public static void main(String[] args) {
.street("15th St")
.place("Washington")
.postcode("20005")
.country("United States")
.build();

final V6ForwardGeocodingRequestOptions requestOptions = V6ForwardGeocodingRequestOptions
.builder(query)
.country("United States")
.types(V6FeatureType.ADDRESS)
.autocomplete(false)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public static V6ForwardGeocodingRequestOptions.Builder builder(
.region(query.region())
.postcode(query.postcode())
.locality(query.locality())
.neighborhood(query.neighborhood());
.neighborhood(query.neighborhood())
.country(query.country());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Call<V6Response> forwardGeocoding(
* @param permanent {@link MapboxV6Geocoding#permanent()}
* @param autocomplete {@link V6ForwardGeocodingRequestOptions#autocomplete()}
* @param bbox {@link V6ForwardGeocodingRequestOptions#bbox()}
* @param country {@link V6ForwardGeocodingRequestOptions#country()}
* @param country {@link V6StructuredInputQuery#country()}
Comment thread
ahmedaly16 marked this conversation as resolved.
* @param language {@link V6ForwardGeocodingRequestOptions#language()}
* @param limit {@link V6ForwardGeocodingRequestOptions#limit()}
* @param proximity {@link V6ForwardGeocodingRequestOptions#proximity()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public abstract class V6StructuredInputQuery {
@Nullable
abstract String neighborhood();

@SerializedName("country")
@Nullable
abstract String country();

/**
* Creates a new {@link V6StructuredInputQuery.Builder} object.
* @return Builder object.
Expand Down Expand Up @@ -149,6 +153,15 @@ public abstract static class Builder {
*/
public abstract Builder neighborhood(@NonNull String neighborhood);

/**
* Generally recognized countries or, in some cases like Hong Kong, an area of quasi-national
* administrative status that has a designated country code under <a href="https://www.iso.org/iso-3166-country-codes.html">ISO 3166-1</a>.
*
* @param country structured input component.
* @return this builder for chaining options together
*/
public abstract Builder country(@NonNull String country);

abstract V6StructuredInputQuery autoBuild();

/**
Expand All @@ -169,6 +182,7 @@ public V6StructuredInputQuery build() {
&& query.postcode() == null
&& query.locality() == null
&& query.neighborhood() == null
&& query.country() == null
) {
throw new ServicesException("At least one component must be non null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public void testStructuredInputRequestParameters() throws InterruptedException,
assertEquals(options.postcode(), url.queryParameter("postcode"));
assertEquals(options.locality(), url.queryParameter("locality"));
assertEquals(options.neighborhood(), url.queryParameter("neighborhood"));
assertEquals(options.country(), url.queryParameter("country"));
}

@Test
Expand Down Expand Up @@ -201,6 +202,7 @@ public void testDefaultStructuredInputRequestParameters() throws InterruptedExce
assertNull(url.queryParameter("postcode"));
assertNull(url.queryParameter("locality"));
assertNull(url.queryParameter("neighborhood"));
assertNull(url.queryParameter("country"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static String removeJsonWhitespaces(String json) {
.postcode("test-postcode")
.locality("test-locality")
.neighborhood("test-neighborhood")
.country("test-country")
.build();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void testStructuredInputWithAllValuesSet() {
.postcode("test-postcode")
.locality("test-locality")
.neighborhood("test-neighborhood")
.country("test-country")
.build();

assertEquals("test-address-line1", query.addressLine1());
Expand All @@ -47,6 +48,7 @@ public void testStructuredInputWithAllValuesSet() {
assertEquals("test-postcode", query.postcode());
assertEquals("test-locality", query.locality());
assertEquals("test-neighborhood", query.neighborhood());
assertEquals("test-country", query.country());
}

@Test
Expand All @@ -63,6 +65,7 @@ public void testUnspecifiedValuesAreNull() {
assertNull(queryWithAddress.postcode());
assertNull(queryWithAddress.locality());
assertNull(queryWithAddress.neighborhood());
assertNull(queryWithAddress.country());

final V6StructuredInputQuery queryWithAddressLine1 = V6StructuredInputQuery.builder()
.addressLine1("test-address-line1")
Expand Down