package common.pages;

import common.prices.PriceFinder;
import common.utils.PriceFormatter;
import common.utils.Translator;
import io.sphere.sdk.models.Image;
import io.sphere.sdk.products.ProductProjection;
import io.sphere.sdk.products.ProductVariant;

public class ProductThumbnailDataBuilder {

    private final Translator translator;
    private final PriceFinder priceFinder;
    private final PriceFormatter priceFormatter;

    private ProductThumbnailDataBuilder(final Translator translator, final PriceFinder priceFinder, final PriceFormatter priceFormatter) {
        this.translator = translator;
        this.priceFinder = priceFinder;
        this.priceFormatter = priceFormatter;
    }

    public static ProductThumbnailDataBuilder of(final Translator translator, final PriceFinder priceFinder, final PriceFormatter priceFormatter) {
        return new ProductThumbnailDataBuilder(translator, priceFinder, priceFormatter);
    }

    public ProductThumbnailData build(final ProductProjection product) {
        final ProductVariant variant = product.getMasterVariant();
        final String text = translator.translate(product.getName());
        final String description = product.getDescription().map(translator::translate).orElse("");
        final String imageUrl = variant.getImages().stream().findFirst().map(Image::getUrl).orElse("");
        final String price = priceFinder.findPrice(variant.getPrices())
                .map(foundPrice -> priceFormatter.format(foundPrice.getValue()))
                .orElse("");

        return new ProductThumbnailData(text, description, imageUrl, price);
    }


}

@@ -1619,12 +1619,10 @@
 ;%0A    %7D%0A
-%0A%0A
 %7D%0A

Remove white space