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

com.commercetools.sunrise.common.ctp.MetricSphereClientProvider Maven / Gradle / Ivy

There is a newer version: 1.0.0-M10
Show newest version
package com.commercetools.sunrise.common.ctp;

import com.google.inject.Provider;
import io.sphere.sdk.client.SphereAccessTokenSupplier;
import io.sphere.sdk.client.SphereClient;
import io.sphere.sdk.client.SphereClientConfig;
import io.sphere.sdk.http.HttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import play.mvc.Http;

import javax.inject.Inject;

public final class MetricSphereClientProvider implements Provider {
    private static final Logger logger = LoggerFactory.getLogger(MetricSphereClientProvider.class);

    @Inject
    private HttpClient httpClient;
    @Inject
    private SphereAccessTokenSupplier sphereAccessTokenSupplier;
    @Inject
    private SphereClientConfig sphereClientConfig;
    @Inject
    private Http.Context context;

    @Override
    public SphereClient get() {
        final MetricHttpClient metricHttpClient = MetricHttpClient.of(httpClient, context);
        logger.info("Provide RequestScopedSphereClient: MetricHttpClient");
        return SphereClient.of(sphereClientConfig, metricHttpClient, sphereAccessTokenSupplier);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy