package com.braintree.converters.populators.configuration;

import com.braintree.enums.BraintreePaymentMethodLimitData;
import com.braintree.hybris.data.BraintreeGooglePayConfigurationData;
import de.hybris.platform.converters.Populator;
import de.hybris.platform.core.model.BraintreeGooglePayConfigurationModel;
import de.hybris.platform.servicelayer.dto.converter.ConversionException;

public class BraintreeGooglePayConfigurationPopulator implements Populator<BraintreeGooglePayConfigurationModel, BraintreeGooglePayConfigurationData> {

    @Override
    public void populate(BraintreeGooglePayConfigurationModel source, BraintreeGooglePayConfigurationData target) throws ConversionException {
        target.setEnabled(source.isEnabled());
        target.setExpressCheckout(source.isEnabled() ? source.isExpressCheckout() : false);
        target.setMerchantId(source.getMerchantId());
        target.setSellerCountryCode(source.getSellerCountryCode());
        target.setSavedGooglePayAccountLimit(BraintreePaymentMethodLimitData.valueOf(source.getSavedGooglePayAccountLimit().getCode()));
    }
}
