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

com.commercetools.sync.inventories.helpers.InventoryCustomActionBuilder Maven / Gradle / Ivy

package com.commercetools.sync.inventories.helpers;

import com.commercetools.api.models.inventory.InventoryEntrySetCustomFieldActionBuilder;
import com.commercetools.api.models.inventory.InventoryEntrySetCustomTypeActionBuilder;
import com.commercetools.api.models.inventory.InventoryEntryUpdateAction;
import com.commercetools.sync.commons.helpers.GenericCustomActionBuilder;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class InventoryCustomActionBuilder
    implements GenericCustomActionBuilder {

  @Nonnull
  @Override
  public InventoryEntryUpdateAction buildRemoveCustomTypeAction(
      @Nullable final Long variantId, @Nullable final String objectId) {
    return InventoryEntrySetCustomTypeActionBuilder.of().build();
  }

  @Nonnull
  @Override
  public InventoryEntryUpdateAction buildSetCustomTypeAction(
      @Nullable final Long variantId,
      @Nullable final String objectId,
      @Nonnull final String customTypeId,
      @Nullable final Map customFieldsJsonMap) {
    return InventoryEntrySetCustomTypeActionBuilder.of()
        .type(typeResourceIdBuilder -> typeResourceIdBuilder.id(customTypeId))
        .fields(fieldContainerBuilder -> fieldContainerBuilder.values(customFieldsJsonMap))
        .build();
  }

  @Nonnull
  @Override
  public InventoryEntryUpdateAction buildSetCustomFieldAction(
      @Nullable final Long variantId,
      @Nullable final String objectId,
      @Nullable final String customFieldName,
      @Nullable final Object customFieldValue) {
    return InventoryEntrySetCustomFieldActionBuilder.of()
        .name(customFieldName)
        .value(customFieldValue)
        .build();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy