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

com.commercetools.sunrise.ctp.project.ProjectProvider Maven / Gradle / Ivy

The newest version!
package com.commercetools.sunrise.ctp.project;

import io.sphere.sdk.client.SphereClient;
import io.sphere.sdk.client.SphereRequest;
import io.sphere.sdk.projects.Project;
import io.sphere.sdk.projects.queries.ProjectGet;

import javax.inject.Inject;
import javax.inject.Provider;
import java.time.Duration;

import static io.sphere.sdk.client.SphereClientUtils.blockingWait;

/**
 * Provides the commercetools {@link Project} associated with the injected {@link SphereClient}.
 */
public final class ProjectProvider implements Provider {

    private final SphereClient sphereClient;

    @Inject
    ProjectProvider(final SphereClient sphereClient) {
        this.sphereClient = sphereClient;
    }

    @Override
    public Project get() {
        final SphereRequest request = ProjectGet.of();
        return blockingWait(sphereClient.execute(request), Duration.ofSeconds(30));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy