package com.braintree.converters.populators.configuration.style;

import com.braintree.hybris.data.ApplePayButtonStyleData;
import de.hybris.platform.converters.Populator;
import de.hybris.platform.core.model.BraintreeApplePayStylesConfigurationModel;
import de.hybris.platform.servicelayer.dto.converter.ConversionException;

public class BraintreeApplePayStyleConfigurationPopulator implements
        Populator<BraintreeApplePayStylesConfigurationModel, ApplePayButtonStyleData> {

    @Override
    public void populate(BraintreeApplePayStylesConfigurationModel braintreeApplePayStylesConfigurationModel,
                         ApplePayButtonStyleData applePayButtonStyleData) throws ConversionException {

        applePayButtonStyleData.setColor(
                formatConfigurationParam(braintreeApplePayStylesConfigurationModel.getColor().name()));
        applePayButtonStyleData.setLocation(
                formatConfigurationParam(braintreeApplePayStylesConfigurationModel.getLocation().name()));
        applePayButtonStyleData.setShape(
                formatConfigurationParam(braintreeApplePayStylesConfigurationModel.getShape().name()));
        applePayButtonStyleData.setType(
                formatConfigurationParam(braintreeApplePayStylesConfigurationModel.getType().name()));
    }

    private String formatConfigurationParam(String param) {
        return param.replaceAll("_", "-").toLowerCase();
    }

}
