io.vrap.rmf.base.client.ClientFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rmf-java-base Show documentation
Show all versions of rmf-java-base Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
package io.vrap.rmf.base.client;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import io.vrap.rmf.base.client.http.*;
import io.vrap.rmf.base.client.oauth2.TokenSupplier;
/**
* @deprecated use {@link ClientBuilder} instead
*/
@Deprecated
public class ClientFactory {
public static final String COMMERCETOOLS = "commercetools";
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier) {
return create(apiBaseUrl, httpClient, tokenSupplier,
(request, topic) -> InternalLogger.getLogger(COMMERCETOOLS + "." + topic), new ArrayList<>(), null);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final Supplier userAgentSupplier) {
return create(apiBaseUrl, httpClient, tokenSupplier,
(request, topic) -> InternalLogger.getLogger(COMMERCETOOLS + "." + topic), userAgentSupplier,
new ArrayList<>(), null);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final List middlewares) {
return create(apiBaseUrl, httpClient, tokenSupplier,
(request, topic) -> InternalLogger.getLogger(COMMERCETOOLS + "." + topic), middlewares, null);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final Supplier userAgentSupplier,
final List middlewares) {
return create(apiBaseUrl, httpClient, tokenSupplier,
(request, topic) -> InternalLogger.getLogger(COMMERCETOOLS + "." + topic), userAgentSupplier, middlewares,
null);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final List middlewares,
final CorrelationIdProvider correlationIdProvider) {
return create(apiBaseUrl, httpClient, tokenSupplier,
(request, topic) -> InternalLogger.getLogger(COMMERCETOOLS + "." + topic), middlewares,
correlationIdProvider);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final Supplier userAgentSupplier,
final List middlewares, final CorrelationIdProvider correlationIdProvider) {
return create(apiBaseUrl, httpClient, tokenSupplier,
(request, topic) -> InternalLogger.getLogger(COMMERCETOOLS + "." + topic), userAgentSupplier, middlewares,
correlationIdProvider);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final InternalLoggerFactory internalLoggerFactory,
List middlewares) {
return create(apiBaseUrl, httpClient, tokenSupplier, internalLoggerFactory, middlewares, null);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final InternalLoggerFactory internalLoggerFactory,
final Supplier userAgentSupplier, List middlewares) {
return create(apiBaseUrl, httpClient, tokenSupplier, internalLoggerFactory, userAgentSupplier, middlewares,
null);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final InternalLoggerFactory internalLoggerFactory,
List middlewares, @Nullable final CorrelationIdProvider correlationIdProvider) {
return create(apiBaseUrl, httpClient, tokenSupplier, internalLoggerFactory,
ClientBuilder::buildDefaultUserAgent, middlewares, correlationIdProvider);
}
public static ApiHttpClient create(final String apiBaseUrl, final VrapHttpClient httpClient,
final TokenSupplier tokenSupplier, final InternalLoggerFactory internalLoggerFactory,
final Supplier userAgentSupplier, List middlewares,
@Nullable final CorrelationIdProvider correlationIdProvider) {
return ClientBuilder.of(httpClient)
.defaultClient(apiBaseUrl)
.withInternalLoggerFactory(internalLoggerFactory)
.withUserAgentSupplier(userAgentSupplier)
.withTokenSupplier(tokenSupplier)
.addCorrelationIdProvider(correlationIdProvider)
.addMiddlewares(middlewares)
.build();
}
}