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

com.commercetools.sync.commons.utils.ClientConfigurationUtils Maven / Gradle / Ivy

Go to download

Java Library used to import and/or sync (taking care of changes) data into one or more commercetools projects from external sources such as CSV, XML, JSON, etc.. or even from an already existing commercetools project.

The newest version!
package com.commercetools.sync.commons.utils;

import com.commercetools.api.client.ProjectApiRoot;
import com.commercetools.api.defaultconfig.ApiRootBuilder;
import io.vrap.rmf.base.client.oauth2.ClientCredentials;
import java.util.Arrays;
import javax.annotation.Nonnull;

public final class ClientConfigurationUtils {

  /**
   * Creates a {@link ProjectApiRoot}.
   *
   * @param projectKey commercetools project key
   * @param credentials api credentials with clientId, clientSecret and scopes
   * @param authUrl the auth url of the commercetools platform that project is bound
   * @param apiUrl the api url of the commercetools platform that project is bound
   * @return the instantiated {@link ProjectApiRoot}.
   */
  public static ProjectApiRoot createClient(
      @Nonnull final String projectKey,
      @Nonnull final ClientCredentials credentials,
      @Nonnull final String authUrl,
      @Nonnull final String apiUrl) {

    return ApiRootBuilder.of()
        .defaultClient(credentials, authUrl, apiUrl)
        .withRetryMiddleware(5, Arrays.asList(500, 502, 503, 504))
        .build(projectKey);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy