All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vrap.rmf.base.client.ClientFactory Maven / Gradle / Ivy

There is a newer version: 17.17.0
Show newest version

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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy