Class ProductVariantPriceUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.products.utils.ProductVariantPriceUpdateActionUtils
-
public final class ProductVariantPriceUpdateActionUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<com.commercetools.api.models.product.ProductUpdateAction>
buildActions(com.commercetools.api.models.product.ProductDraft newProduct, java.lang.Long variantId, com.commercetools.api.models.common.Price oldPrice, com.commercetools.api.models.common.PriceDraft newPrice, ProductSyncOptions syncOptions)
Compares all the fields of aPrice
and aPriceDraft
and returns a list ofstatic java.util.Optional<com.commercetools.api.models.product.ProductUpdateAction>
buildChangePriceUpdateAction(com.commercetools.api.models.common.Price oldPrice, com.commercetools.api.models.common.PriceDraft newPrice, ProductSyncOptions syncOptions)
Builds aProductChangePriceAction
action based on the comparison of the following fields of the suppliedPrice
andPriceDraft
:Price.getValue()
andPriceDraft.getValue()
Price.getTiers()
andPriceDraft.getTiers()
static java.util.List<com.commercetools.api.models.product.ProductUpdateAction>
buildCustomUpdateActions(com.commercetools.api.models.product.ProductDraft newProduct, java.lang.Long variantId, com.commercetools.api.models.common.Price oldPrice, com.commercetools.api.models.common.PriceDraft newPrice, ProductSyncOptions syncOptions)
Compares the custom fields and custom types of aPrice
and aPriceDraft
and
-
-
-
Method Detail
-
buildActions
@Nonnull public static java.util.List<com.commercetools.api.models.product.ProductUpdateAction> buildActions(@Nonnull com.commercetools.api.models.product.ProductDraft newProduct, @Nonnull java.lang.Long variantId, @Nonnull com.commercetools.api.models.common.Price oldPrice, @Nonnull com.commercetools.api.models.common.PriceDraft newPrice, @Nonnull ProductSyncOptions syncOptions)
Compares all the fields of aPrice
and aPriceDraft
and returns a list ofProductUpdateAction
<Product
> as a result. If both thePrice
and thePriceDraft
have identical fields, then no update action is needed and hence an emptyList
is returned.- Parameters:
newProduct
- new product draft, which provides the prices to update.variantId
- the variantId needed for building the update action.oldPrice
- the price which should be updated.newPrice
- the price draft where we get the new fields.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- A list with the update actions or an empty list if the price fields are identical.
-
buildChangePriceUpdateAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.product.ProductUpdateAction> buildChangePriceUpdateAction(@Nonnull com.commercetools.api.models.common.Price oldPrice, @Nonnull com.commercetools.api.models.common.PriceDraft newPrice, @Nonnull ProductSyncOptions syncOptions)
Builds aProductChangePriceAction
action based on the comparison of the following fields of the suppliedPrice
andPriceDraft
:Price.getValue()
andPriceDraft.getValue()
Price.getTiers()
andPriceDraft.getTiers()
If any of the aforementioned fields are different a
ProductChangePriceAction
update action will be returned in anOptional
, otherwise if both are identical in thePrice
and thePriceDraft
, then no update action is needed and hence an emptyOptional
is returned.- Parameters:
oldPrice
- the price which should be updated.newPrice
- the price draft where we get the new name.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- A filled optional with the update action or an empty optional if the names are identical.
-
buildCustomUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.product.ProductUpdateAction> buildCustomUpdateActions(@Nonnull com.commercetools.api.models.product.ProductDraft newProduct, @Nonnull java.lang.Long variantId, @Nonnull com.commercetools.api.models.common.Price oldPrice, @Nonnull com.commercetools.api.models.common.PriceDraft newPrice, @Nonnull ProductSyncOptions syncOptions)
Compares the custom fields and custom types of aPrice
and aPriceDraft
andreturns a list of
ProductUpdateAction
<Product
> as a result. If both thePrice
and thePriceDraft
have identical custom fields and types, then no update action is needed and hence an emptyList
is returned.- Parameters:
newProduct
- new product draft, which provides the prices to update.variantId
- the variantId needed for building the update action.oldPrice
- the price which should be updated.newPrice
- the price draft where we get the new custom fields and types.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- A list with the custom field/type update actions or an empty list if the custom fields/types are identical.
-
-