global.maplink.geocode.async.GeocodeAsyncAPI Maven / Gradle / Ivy
package global.maplink.geocode.async;
import global.maplink.MapLinkSDK;
import global.maplink.env.Environment;
import global.maplink.geocode.extensions.GeocodeExtensionManager;
import global.maplink.geocode.schema.Type;
import global.maplink.geocode.schema.crossCities.CrossCitiesRequest;
import global.maplink.geocode.schema.reverse.ReverseRequest;
import global.maplink.geocode.schema.structured.StructuredRequest;
import global.maplink.geocode.schema.suggestions.SuggestionsRequest;
import global.maplink.geocode.schema.suggestions.SuggestionsResult;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import static global.maplink.MapLinkServiceRequestAsyncRunner.createRunner;
import static java.util.Arrays.asList;
public interface GeocodeAsyncAPI {
default CompletableFuture suggestions(String query) {
return suggestions(SuggestionsRequest.builder().query(query).build());
}
default CompletableFuture suggestions(String query, Type type) {
return suggestions(SuggestionsRequest.builder().query(query).type(type).build());
}
CompletableFuture suggestions(SuggestionsRequest request);
CompletableFuture structured(StructuredRequest request);
default CompletableFuture reverse(ReverseRequest.Entry... request) {
return reverse(asList(request));
}
default CompletableFuture reverse(List request) {
return reverse(ReverseRequest.of(request));
}
CompletableFuture reverse(ReverseRequest request);
default CompletableFuture crossCities(CrossCitiesRequest.Point... points) {
return crossCities(asList(points));
}
default CompletableFuture crossCities(List points) {
return crossCities(CrossCitiesRequest.of(points));
}
CompletableFuture crossCities(CrossCitiesRequest request);
static GeocodeAsyncAPI getInstance() {
return getInstance(null);
}
static GeocodeAsyncAPI getInstance(Environment environment) {
MapLinkSDK sdk = MapLinkSDK.getInstance();
return new GeocodeAsyncApiImpl(
createRunner(
Optional.ofNullable(environment).orElse(sdk.getEnvironment()),
sdk
),
GeocodeExtensionManager.from(sdk.getExtensions())
);
}
}