All Downloads are FREE. Search and download functionalities are using the official Maven repository.

global.maplink.toll.async.TollAsyncAPI Maven / Gradle / Ivy

package global.maplink.toll.async;

import global.maplink.MapLinkSDK;
import global.maplink.env.Environment;
import global.maplink.toll.schema.Billing;
import global.maplink.toll.schema.request.LegRequest;
import global.maplink.toll.schema.request.TollCalculationRequest;
import global.maplink.toll.schema.result.TollCalculationResult;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import static global.maplink.MapLinkServiceRequestAsyncRunner.proxyFor;
import static java.util.Arrays.asList;

public interface TollAsyncAPI {

    default CompletableFuture calculate(LegRequest... legs) {
        return calculate(asList(legs));
    }

    default CompletableFuture calculate(Billing billing, LegRequest... legs) {
        return calculate(billing, asList(legs));
    }

    default CompletableFuture calculate(List legs) {
        return calculate(
                TollCalculationRequest.builder()
                        .legs(legs)
                        .build()
        );
    }

    default CompletableFuture calculate(Billing billing, List legs) {
        return calculate(
                TollCalculationRequest.builder()
                        .billing(billing)
                        .legs(legs)
                        .build()
        );
    }

    CompletableFuture calculate(TollCalculationRequest request);

    static TollAsyncAPI getInstance() {
        return getInstance(null);
    }

    static TollAsyncAPI getInstance(Environment environment) {
        MapLinkSDK sdk = MapLinkSDK.getInstance();
        return proxyFor(
                TollAsyncAPI.class,
                Optional.ofNullable(environment).orElse(sdk.getEnvironment()),
                sdk
        );
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy