public interface SphereClientFactory
CompletionStage
as future implementation.
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.
Modifier and Type | Method and Description |
---|---|
default SphereClient |
createClient(SphereApiConfig config,
SphereAccessTokenSupplier tokenSupplier)
Creates a client with a custom service to provide access tokens.
|
default SphereClient |
createClient(SphereClientConfig config)
Creates a standard client with configurable service URLs.
|
default SphereClient |
createClient(String projectKey,
String clientId,
String clientSecret)
Creates a standard client suitable for online shops.
|
default SphereClient |
createClient(String projectKey,
String clientId,
String clientSecret,
String authUrl,
String apiUrl)
Creates a standard client suitable for online shops.
|
default SphereClient |
createClientOfApiConfigAndAccessToken(SphereApiConfig config,
String accessToken)
Creates a client which relies on an access token and does not refresh it.
|
default SphereClient |
createClientOfApiConfigAndAccessToken(SphereApiConfig config,
String accessToken,
HttpClient httpClient)
Creates a client which relies on an access token and does not refresh it, it reuses an existing http client.
|
HttpClient |
createHttpClient() |
static SphereClientFactory |
of() |
static SphereClientFactory |
of(Supplier<HttpClient> httpClientSupplier) |
HttpClient createHttpClient()
default SphereClient createClient(SphereClientConfig config)
config
- configuration for the clientdefault SphereClient createClient(SphereApiConfig config, SphereAccessTokenSupplier tokenSupplier)
config
- the configuration to use the APItokenSupplier
- a service which provides tokensdefault SphereClient createClient(String projectKey, String clientId, String clientSecret)
projectKey
- the project identifierclientId
- usernameclientSecret
- passworddefault SphereClient createClient(String projectKey, String clientId, String clientSecret, String authUrl, String apiUrl)
projectKey
- the project identifierclientId
- usernameclientSecret
- passwordauthUrl
- authentication url for the ApiapiUrl
- api url for the Apidefault SphereClient createClientOfApiConfigAndAccessToken(SphereApiConfig config, String accessToken, HttpClient httpClient)
config
- the configuration to use the APIaccessToken
- the token belonging to the project in config
httpClient
- the http client used for performing requestsdefault SphereClient createClientOfApiConfigAndAccessToken(SphereApiConfig config, String accessToken)
config
- the configuration to use the APIaccessToken
- the token belonging to the project in config
static SphereClientFactory of(Supplier<HttpClient> httpClientSupplier)
static SphereClientFactory of()