public interface SphereClient extends AutoCloseable
import io.sphere.sdk.client.SphereClient;
import io.sphere.sdk.client.SphereClientFactory;
public class JavaClientInstantiationExample { public void instantiate() { final SphereClientFactory factory = SphereClientFactory.of(); final SphereClient client = factory.createClient( "jvm-sdk-dev-1", //replace with your project key "ELqF0rykXD2fyS8s-IhIPKfQ", //replace with your client id "222222222222222222222222222222226"); //replace with your client secret } }
See the test code.
CompletionStage<PagedQueryResult<TaxCategory>> future = client.execute(TaxCategoryQuery.of().byName("de19"));
See the test code.
Modifier and Type | Method and Description |
---|---|
void |
close()
Shuts down the client to save resources like connections and threads.
|
<T> CompletionStage<T> |
execute(SphereRequest<T> sphereRequest)
Executes asynchronously a request to Composable Commerce.
|
SphereApiConfig |
getConfig()
Getter for the SphereApiConfig used for this client
|
static SphereClient |
of(SphereApiConfig config,
HttpClient httpClient,
SphereAccessTokenSupplier tokenSupplier)
Raw client creation.
|
static SphereClient |
of(SphereApiConfig config,
HttpClient httpClient,
SphereAccessTokenSupplier tokenSupplier,
List<SolutionInfo> additionalSolutionInfos)
Raw client creation.
|
<T> CompletionStage<T> execute(SphereRequest<T> sphereRequest)
T
- type of the result for the requestsphereRequest
- request to Composable Commerce to performvoid close()
close
in interface AutoCloseable
static SphereClient of(SphereApiConfig config, HttpClient httpClient, SphereAccessTokenSupplier tokenSupplier)
SphereClientFactory
.config
- Project and locationhttpClient
- client to execute requeststokenSupplier
- delivery of access tokensstatic SphereClient of(SphereApiConfig config, HttpClient httpClient, SphereAccessTokenSupplier tokenSupplier, List<SolutionInfo> additionalSolutionInfos)
config
- Project and locationhttpClient
- client to execute requeststokenSupplier
- delivery of access tokensSphereApiConfig getConfig()
SphereApiConfig