com.microsoft.bingads.v13.bulk.entities.BulkPriceAdExtension 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.ArrayList;
import java.util.Collections;
import java.util.List;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import com.microsoft.bingads.v13.bulk.BulkFileReader;
import com.microsoft.bingads.v13.bulk.BulkFileWriter;
import com.microsoft.bingads.v13.bulk.BulkOperation;
import com.microsoft.bingads.v13.bulk.BulkServiceManager;
import com.microsoft.bingads.v13.campaignmanagement.ArrayOfPriceTableRow;
import com.microsoft.bingads.v13.campaignmanagement.PriceAdExtension;
import com.microsoft.bingads.v13.campaignmanagement.PriceExtensionType;
import com.microsoft.bingads.v13.internal.bulk.BulkMapping;
import com.microsoft.bingads.v13.internal.bulk.ComplexBulkMapping;
import com.microsoft.bingads.v13.internal.bulk.MappingHelpers;
import com.microsoft.bingads.v13.internal.bulk.RowValues;
import com.microsoft.bingads.v13.internal.bulk.SimpleBulkMapping;
import com.microsoft.bingads.v13.internal.bulk.StringExtensions;
import com.microsoft.bingads.v13.internal.bulk.StringTable;
/**
* Represents a price ad extension that can be read or written in a bulk file.
* This class exposes the properties
* that can be read and written as fields of the Price Ad Extension record in a
* bulk file.
*
* For more information, see Price Ad Extension at
* https://go.microsoft.com/fwlink/?linkid=846127
*
* @see BulkServiceManager
* @see BulkOperation
* @see BulkFileReader
* @see BulkFileWriter
*/
public class BulkPriceAdExtension extends BulkAdExtension {
/**
* Gets the price ad extension.
*/
public PriceAdExtension getPriceAdExtension() {
return getAdExtension();
}
/**
* Sets the price ad extension.
*/
public void setPriceAdExtension(PriceAdExtension priceAdExtension) {
setAdExtension(priceAdExtension);
}
private static final List> MAPPINGS;
static {
List> m = new ArrayList>();
m.add(new SimpleBulkMapping(
StringTable.Language,
new Function() {
@Override
public String apply(BulkPriceAdExtension c) {
return c.getAdExtension().getLanguage();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkPriceAdExtension c) {
c.getPriceAdExtension().setLanguage(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.PriceExtensionType,
new Function() {
@Override
public String apply(BulkPriceAdExtension c) {
PriceExtensionType priceExtensionType = c.getPriceAdExtension().getPriceExtensionType();
return priceExtensionType == null ? null : priceExtensionType.value();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkPriceAdExtension c) {
c.getPriceAdExtension().setPriceExtensionType(StringExtensions.parseOptional(v, new Function() {
@Override
public PriceExtensionType apply(String s) {
return PriceExtensionType.fromValue(s);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.TrackingTemplate,
new Function() {
@Override
public String apply(BulkPriceAdExtension c) {
return StringExtensions.toOptionalBulkString(c.getAdExtension().getTrackingUrlTemplate(), c.getAdExtension().getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkPriceAdExtension c) {
c.getAdExtension().setTrackingUrlTemplate(StringExtensions.getValueOrEmptyString(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.CustomParameter,
new Function() {
@Override
public String apply(BulkPriceAdExtension c) {
return StringExtensions.toCustomParaBulkString(c.getAdExtension().getUrlCustomParameters(), c.getAdExtension().getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkPriceAdExtension c) {
try {
c.getAdExtension().setUrlCustomParameters(StringExtensions.parseCustomParameters(v));
} catch (Exception e) {
e.printStackTrace();
}
}
}
));
m.add(new ComplexBulkMapping(
new BiConsumer() {
@Override
public void accept(BulkPriceAdExtension c, RowValues v) {
PriceAdExtension priceAdExtension = c.getPriceAdExtension();
if (priceAdExtension == null || priceAdExtension.getTableRows() == null) {
return;
}
PriceTableRowHelper.addRowValuesFromPriceTableRows(priceAdExtension.getTableRows(), v, priceAdExtension.getId());
}
},
new BiConsumer() {
@Override
public void accept(RowValues v, BulkPriceAdExtension c) {
PriceAdExtension priceAdExtension = c.getPriceAdExtension();
if (priceAdExtension != null) {
priceAdExtension.setTableRows(new ArrayOfPriceTableRow());
PriceTableRowHelper.addPriceTableRowsFromRowValues(v, priceAdExtension.getTableRows());
}
}
}
));
m.add(new SimpleBulkMapping(StringTable.FinalUrlSuffix,
new Function() {
@Override
public String apply(BulkPriceAdExtension c) {
return StringExtensions.toOptionalBulkString(c.getAdExtension().getFinalUrlSuffix(), c.getAdExtension().getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkPriceAdExtension c) {
c.getAdExtension().setFinalUrlSuffix(StringExtensions.getValueOrEmptyString(v));
}
}
));
MAPPINGS = Collections.unmodifiableList(m);
}
@Override
public void processMappingsFromRowValues(RowValues values) {
PriceAdExtension extension = new PriceAdExtension();
extension.setType("PriceAdExtension");
setAdExtension(extension);
super.processMappingsFromRowValues(values);
MappingHelpers.convertToEntity(values, MAPPINGS, this);
}
@Override
public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
validatePropertyNotNull(this.getPriceAdExtension(), "PriceAdExtension");
super.processMappingsToRowValues(values, excludeReadonlyData);
MappingHelpers.convertToValues(this, values, MAPPINGS);
}
}