io.sphere.sdk.client.SphereClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-java-client-core Show documentation
Show all versions of commercetools-java-client-core Show documentation
This SDK is announced to be deprecated latest by 31 December 2022, please follow more details on SDK deprecation plan https://docs.commercetools.com/api/releases/2021-08-31-announced-long-term-support-plan-for-commercetools-sdks. We recommend you to use our new SDK here https://docs.commercetools.com/sdk/jvm-sdk#java-sdk-v2.
package io.sphere.sdk.client;
import io.sphere.sdk.http.HttpClient;
import java.util.concurrent.CompletionStage;
/**
* A client interface to perform requests to the platform.
*
* Instantiation
*
* {@include.example example.JavaClientInstantiationExample}
*
* Example call
*
* {@include.example example.TaxCategoryQueryExample#exampleQuery()}
*
* Refer to resources for known platform requests.
*
*/
public interface SphereClient extends AutoCloseable {
/**
* Executes asynchronously a request to commercetools. By default it does not have a timeout.
* @param sphereRequest request to commercetools to perfom
* @param type of the result for the request
* @return future monad which can contain the result or an exception
*/
CompletionStage execute(final SphereRequest sphereRequest);
/**
* Shuts down the client to save resources like connections and threads.
*/
@Override
void close();
/**
* Raw client creation.
* See also SphereClientFactory.
*
* @param config platform project and location
* @param httpClient client to execute requests
* @param tokenSupplier delivery of access tokens
* @return sphere client
*/
static SphereClient of(final SphereApiConfig config, final HttpClient httpClient, final SphereAccessTokenSupplier tokenSupplier) {
return SphereClientImpl.of(config, httpClient, tokenSupplier, CorrelationIdGenerator.of(config.getProjectKey()));
}
/**
* Getter for the SphereApiConfig used for this client
* @return the configuration used for this client
* @see SphereApiConfig
*/
SphereApiConfig getConfig();
}