All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.bingads.v13.bulk.entities.ProductConditionHelper Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 13.0.22.1
Show newest version
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);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy