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

com.commercetools.sync.services.ChannelService 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.services;

import com.commercetools.api.models.channel.Channel;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;

public interface ChannelService {

  /**
   * Filters out the keys which are already cached and fetches only the not-cached channel keys from
   * the CTP project defined in an injected {@link com.commercetools.api.client.ProjectApiRoot} and
   * stores a mapping for every channel to id in the cached map of keys -> ids and returns this
   * cached map.
   *
   * @param channelKeys - a set of channel keys to fetch and cache the ids for
   * @return {@link CompletionStage}<{@link Map}> in which the result of it's completion
   *     contains a map of requested tax channel -> ids
   */
  @Nonnull
  CompletionStage> cacheKeysToIds(@Nonnull final Set channelKeys);

  /**
   * Given a {@code key}, this method first checks if a cached map of channel keys -> ids is not
   * empty. If not, it returns a completed future that contains an optional that contains what this
   * key maps to in the cache. If the cache is empty, the method populates the cache with the
   * mapping of all channels' keys to ids in the CTP project, by querying the CTP project channels.
   *
   * 

After that, the method returns a {@link CompletionStage}<{@link Optional}<{@link * String}>> in which the result of it's completion could contain an {@link Optional} with * the id inside of it or an empty {@link Optional} if no {@link Channel} was found in the CTP * project with this key. * * @param key the key by which a {@link Channel} id should be fetched from the CTP project. * @return {@link CompletionStage}<{@link Optional}<{@link String}>> in which the * result of it's completion could contain an {@link Optional} with the id inside of it or an * empty {@link Optional} if no {@link Channel} was found in the CTP project with this * external id. */ @Nonnull CompletionStage> fetchCachedChannelId(@Nonnull String key); /** * Creates a new channel with the supplied {@code key}. * * @param key key of supply channel. * @return a future containing as a result the created {@link Channel} or empty optional. */ @Nonnull CompletionStage> createChannel(@Nonnull final String key); /** * Creates a new channel with the supplied {@code key} and puts a new mapping of it's key to id in * a cache map. * * @param key key of supply channel. * @return a future containing as a result the created {@link Channel} or empty optional. */ @Nonnull CompletionStage> createAndCacheChannel(@Nonnull final String key); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy