com.microsoft.bingads.v13.bulk.entities.ProductConditionHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of microsoft.bingads Show documentation
Show all versions of microsoft.bingads Show documentation
The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.
package com.microsoft.bingads.v13.bulk.entities;
import java.util.List;
import com.microsoft.bingads.v13.campaignmanagement.ArrayOfProductCondition;
import com.microsoft.bingads.v13.campaignmanagement.ProductCondition;
import com.microsoft.bingads.v13.internal.bulk.RowValues;
import com.microsoft.bingads.v13.internal.bulk.StringTable;
class ProductConditionHelper {
public static final int MaxNumberOfConditions = 8;
public static void addRowValuesFromConditions(ArrayOfProductCondition arrayOfProductCondition, RowValues rowValues) {
List conditions = arrayOfProductCondition.getProductConditions();
for (int i = 1; i <= conditions.size(); i++) {
rowValues.put(StringTable.ProductConditionColumnPrefix + i, conditions.get(i - 1).getOperand());
rowValues.put(StringTable.ProductValueColumnPrefix + i, conditions.get(i - 1).getAttribute());
}
}
public static void addConditionsFromRowValues(RowValues values,
ArrayOfProductCondition productConditionArray) {
List conditions = productConditionArray.getProductConditions();
for (int i = 1; i <= MaxNumberOfConditions; i++) {
String productCondition;
String productValue;
productCondition = values.tryGet(StringTable.ProductConditionColumnPrefix + i);
productValue = values.tryGet(StringTable.ProductValueColumnPrefix + i);
if (productCondition != null && !productCondition.isEmpty() && productValue != null && !productValue.isEmpty()) {
ProductCondition condition = new ProductCondition();
condition.setAttribute(productValue);
condition.setOperand(productCondition);
conditions.add(condition);
}
}
}
}