
com.commercetools.payment.utils.impl.PaymentConnectorHelperImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
The commercetools java payment project intend is to make payment integration easy
The newest version!
package com.commercetools.payment.utils.impl;
import com.commercetools.payment.model.HttpRequestResult;
import com.commercetools.payment.utils.PaymentConnectorHelper;
import io.sphere.sdk.client.SphereClientFactory;
import io.sphere.sdk.http.HttpClient;
import io.sphere.sdk.http.HttpMethod;
import io.sphere.sdk.http.HttpRequest;
import javax.annotation.Nonnull;
import java.util.concurrent.CompletionStage;
/**
* Created by mgatz on 7/28/16.
*/
public class PaymentConnectorHelperImpl implements PaymentConnectorHelper {
@Override
@Nonnull
public CompletionStage sendHttpGetRequest(String url) {
HttpRequest request = HttpRequest.of(HttpMethod.GET, url);
HttpClient client = SphereClientFactory.of().createHttpClient();
return client.execute(request)
.thenApplyAsync(response -> HttpRequestResult.of(request, response, null))
.exceptionally(throwable -> HttpRequestResult.of(request, null, throwable))
.whenCompleteAsync((response, throwable) -> client.close());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy