com.microsoft.bingads.v13.bulk.entities.BulkAccount Maven / Gradle / Ivy
Show all versions of microsoft.bingads Show documentation
package com.microsoft.bingads.v13.bulk.entities;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import com.microsoft.bingads.internal.UncheckedParseException;
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.internal.bulk.BulkMapping;
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;
import com.microsoft.bingads.v13.internal.bulk.entities.SingleRecordBulkEntity;
/**
* Represents an account that can be read or written in a bulk file.
*
*
* Properties of this class and of classes that it is derived from, correspond to fields of the Account record in a bulk file.
* For more information, see Account at
* https://go.microsoft.com/fwlink/?linkid=846127.
*
*
* @see BulkServiceManager
* @see BulkOperation
* @see BulkFileReader
* @see BulkFileWriter
*/
public class BulkAccount extends SingleRecordBulkEntity {
private long id;
private long customerId;
private Calendar syncTime;
private Boolean MSCLKIDAutoTaggingEnabled;
private Boolean includeViewThroughConversions;
private Boolean profileExpansionEnabled;
private String trackingUrlTemplate;
private String finalUrlSuffix;
private Boolean adClickParallelTracking;
private Map autoApplyRecommendations;
private Boolean allowImageAutoRetrieve;
private List businessAttributes;
private static final List> MAPPINGS;
static {
List> m = new ArrayList>();
m.add(new SimpleBulkMapping(StringTable.Id,
new Function() {
@Override
public Long apply(BulkAccount t) {
return t.getId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setId(Long.parseLong(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.ParentId,
new Function() {
@Override
public Long apply(BulkAccount t) {
return t.getCustomerId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setCustomerId(StringExtensions.parseOptional(v, new Function() {
@Override
public Long apply(String value) {
return Long.parseLong(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.SyncTime,
new Function() {
@Override
public String apply(BulkAccount t) {
if (t.getSyncTime() == null) {
return null;
}
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format.format(t.getSyncTime().getTime());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setSyncTime(StringExtensions.parseOptional(v, new Function() {
@Override
public Calendar apply(String t) {
Calendar c = new GregorianCalendar();
try {
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("UTC"));
c.setTime(format.parse(t));
} catch (ParseException ex) {
throw new UncheckedParseException(ex);
}
return c;
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.MSCLKIDAutoTaggingEnabled,
new Function() {
@Override
public Boolean apply(BulkAccount t) {
return t.getMSCLKIDAutoTaggingEnabled();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setMSCLKIDAutoTaggingEnabled(v == null ? null : Boolean.parseBoolean(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.TrackingTemplate,
new Function() {
@Override
public String apply(BulkAccount t) {
return t.getTrackingUrlTemplate();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setTrackingUrlTemplate(StringExtensions.getValueOrEmptyString(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.FinalUrlSuffix,
new Function() {
@Override
public String apply(BulkAccount c) {
return StringExtensions.toOptionalBulkString(c.getFinalUrlSuffix(), c.getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setFinalUrlSuffix(StringExtensions.getValueOrEmptyString(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.IncludeViewThroughConversions,
new Function() {
@Override
public Boolean apply(BulkAccount t) {
return t.getIncludeViewThroughConversions();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setIncludeViewThroughConversions(v == null ? null : Boolean.parseBoolean(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.ProfileExpansionEnabled,
new Function() {
@Override
public Boolean apply(BulkAccount t) {
return t.getProfileExpansionEnabled();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setProfileExpansionEnabled(v == null ? null : Boolean.parseBoolean(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.AdClickParallelTracking,
new Function() {
@Override
public Boolean apply(BulkAccount t) {
return t.getAdClickParallelTracking();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setAdClickParallelTracking(v == null ? null : Boolean.parseBoolean(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.AutoApplyRecommendations,
new Function() {
@Override
public String apply(BulkAccount t) {
return StringExtensions.writeAutoApplyRecommendations(";", t.getAutoApplyRecommendations());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setAutoApplyRecommendations(StringExtensions.parseAutoApplyRecommendations(v, ";"));
}
}
));
m.add(new SimpleBulkMapping(StringTable.BusinessAttributes,
new Function() {
@Override
public String apply(BulkAccount t) {
return StringExtensions.writeBusinessAttributes(";", t.getBusinessAttributes());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setBusinessAttributes(StringExtensions.parseBusinessAttributes(v, ";"));
}
}
));
m.add(new SimpleBulkMapping(StringTable.AllowImageAutoRetrieve,
new Function() {
@Override
public Boolean apply(BulkAccount t) {
return t.getAllowImageAutoRetrieve();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAccount c) {
c.setAllowImageAutoRetrieve(v == null ? null : Boolean.parseBoolean(v));
}
}
));
MAPPINGS = Collections.unmodifiableList(m);
}
/**
* Gets the identifier of the account.
*
*
* Corresponds to the 'Id' field in the bulk file.
*
*/
public long getId() {
return id;
}
/**
* Sets the identifier of the account.
*
*
* Corresponds to the 'Id' field in the bulk file.
*
*/
public void setId(long id) {
this.id = id;
}
/**
* Gets the identifier of the customer that contains the account.
*
*
* Corresponds to the 'Parent Id' field in the bulk file.
*
*/
public long getCustomerId() {
return customerId;
}
/**
* Sets the identifier of the customer that contains the account.
*
*
* Corresponds to the 'Parent Id' field in the bulk file.
*
*/
public void setCustomerId(long customerId) {
this.customerId = customerId;
}
/**
* Gets the date and time that you last synced your account using the bulk service.
*
*
* You should keep track of this value in UTC time.
* Corresponds to the 'Sync Time' field in the bulk file.
*
*/
public Calendar getSyncTime() {
return syncTime;
}
/**
* Sets the date and time that you last synced your account using the bulk service.
*
*
* You should keep track of this value in UTC time.
* Corresponds to the 'Sync Time' field in the bulk file.
*
*/
public void setSyncTime(Calendar syncTime) {
this.syncTime = syncTime;
}
public Boolean getMSCLKIDAutoTaggingEnabled() {
return MSCLKIDAutoTaggingEnabled;
}
public void setMSCLKIDAutoTaggingEnabled(Boolean msclkAutoTagEnabled) {
this.MSCLKIDAutoTaggingEnabled = msclkAutoTagEnabled;
}
public Boolean getIncludeViewThroughConversions() {
return includeViewThroughConversions;
}
public void setIncludeViewThroughConversions(Boolean includeViewThroughConversions) {
this.includeViewThroughConversions = includeViewThroughConversions;
}
public Boolean getProfileExpansionEnabled() {
return profileExpansionEnabled;
}
public void setProfileExpansionEnabled(Boolean profileExpansionEnabled) {
this.profileExpansionEnabled = profileExpansionEnabled;
}
public String getTrackingUrlTemplate() {
return trackingUrlTemplate;
}
public void setTrackingUrlTemplate(String trackingTemplate) {
this.trackingUrlTemplate = trackingTemplate;
}
public String getFinalUrlSuffix() {
return finalUrlSuffix;
}
public void setFinalUrlSuffix(String finalUrlSuffix) {
this.finalUrlSuffix = finalUrlSuffix;
}
public Boolean getAdClickParallelTracking() {
return adClickParallelTracking;
}
public void setAdClickParallelTracking(Boolean adClickParallelTracking) {
this.adClickParallelTracking = adClickParallelTracking;
}
public Map getAutoApplyRecommendations() {
return autoApplyRecommendations;
}
public void setAutoApplyRecommendations(Map autoApplyRecommendations) {
this.autoApplyRecommendations = autoApplyRecommendations;
}
public List getBusinessAttributes() {
return businessAttributes;
}
public void setBusinessAttributes(List businessAttributes) {
this.businessAttributes = businessAttributes;
}
public Boolean getAllowImageAutoRetrieve() {
return allowImageAutoRetrieve;
}
public void setAllowImageAutoRetrieve(Boolean allowImageAutoRetrieve) {
this.allowImageAutoRetrieve = allowImageAutoRetrieve;
}
@Override
public void processMappingsFromRowValues(RowValues values) {
MappingHelpers.convertToEntity(values, MAPPINGS, this);
}
@Override
public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
MappingHelpers.convertToValues(this, values, MAPPINGS);
}
}