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

com.microsoft.bingads.v13.bulk.entities.BulkOfflineConversion 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.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.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.campaignmanagement.OfflineConversion;
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 a label that can be read or written in a bulk file.
 *
 * 

* For more information, see Label at * https://go.microsoft.com/fwlink/?linkid=846127. *

* * @see BulkServiceManager * @see BulkOperation * @see BulkFileReader * @see BulkFileWriter */ public class BulkOfflineConversion extends SingleRecordBulkEntity { private OfflineConversion offlineConversion; private Double adjustmentValue; private Calendar adjustmentTime; private String adjustmentCurrencyCode; private String adjustmentType; private String externalAttributionModel; private Double externalAttributionCredit; private static final List> MAPPINGS; static { List> m = new ArrayList>(); m.add(new SimpleBulkMapping(StringTable.ConversionCurrencyCode, new Function() { @Override public String apply(BulkOfflineConversion c) { return c.getOfflineConversion().getConversionCurrencyCode(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.getOfflineConversion().setConversionCurrencyCode(v); } } )); m.add(new SimpleBulkMapping(StringTable.ConversionName, new Function() { @Override public String apply(BulkOfflineConversion c) { return c.getOfflineConversion().getConversionName(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.getOfflineConversion().setConversionName(v); } } )); m.add(new SimpleBulkMapping(StringTable.MicrosoftClickId, new Function() { @Override public String apply(BulkOfflineConversion c) { return c.getOfflineConversion().getMicrosoftClickId(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.getOfflineConversion().setMicrosoftClickId(v); } } )); m.add(new SimpleBulkMapping(StringTable.ConversionTime, new Function() { @Override public String apply(BulkOfflineConversion t) { if (t.getOfflineConversion().getConversionTime() == null) { return null; } SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("UTC")); return format.format(t.getOfflineConversion().getConversionTime().getTime()); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.getOfflineConversion().setConversionTime(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.ConversionValue, new Function() { @Override public Double apply(BulkOfflineConversion c) { return c.getOfflineConversion().getConversionValue(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.getOfflineConversion().setConversionValue(StringExtensions.nullOrDouble(v)); } } )); m.add(new SimpleBulkMapping(StringTable.AdjustmentValue, new Function() { @Override public Double apply(BulkOfflineConversion c) { return c.getAdjustmentValue(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.setAdjustmentValue(StringExtensions.nullOrDouble(v)); } } )); m.add(new SimpleBulkMapping(StringTable.ExternalAttributionCredit, new Function() { @Override public Double apply(BulkOfflineConversion c) { return c.getExternalAttributionCredit(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.setExternalAttributionCredit(StringExtensions.nullOrDouble(v)); } } )); m.add(new SimpleBulkMapping(StringTable.AdjustmentTime, new Function() { @Override public String apply(BulkOfflineConversion t) { if (t.getAdjustmentTime() == null) { return null; } SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("UTC")); return format.format(t.getAdjustmentTime().getTime()); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.setAdjustmentTime(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.AdjustmentCurrencyCode, new Function() { @Override public String apply(BulkOfflineConversion c) { return c.getAdjustmentCurrencyCode(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.setAdjustmentCurrencyCode(v); } } )); m.add(new SimpleBulkMapping(StringTable.AdjustmentType, new Function() { @Override public String apply(BulkOfflineConversion c) { return c.getAdjustmentType(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.setAdjustmentType(v); } } )); m.add(new SimpleBulkMapping(StringTable.ExternalAttributionModel, new Function() { @Override public String apply(BulkOfflineConversion c) { return c.getExternalAttributionModel(); } }, new BiConsumer() { @Override public void accept(String v, BulkOfflineConversion c) { c.setExternalAttributionModel(v); } } )); MAPPINGS = Collections.unmodifiableList(m); } public OfflineConversion getOfflineConversion() { return offlineConversion; } public void setOfflineConversion(OfflineConversion offlineConversion) { this.offlineConversion = offlineConversion; } public Double getAdjustmentValue() { return adjustmentValue; } public void setAdjustmentValue(Double adjustmentValue) { this.adjustmentValue = adjustmentValue; } public Calendar getAdjustmentTime() { return adjustmentTime; } public void setAdjustmentTime(Calendar adjustmentTime) { this.adjustmentTime = adjustmentTime; } public String getAdjustmentCurrencyCode() { return adjustmentCurrencyCode; } public void setAdjustmentCurrencyCode(String adjustmentCurrencyCode) { this.adjustmentCurrencyCode = adjustmentCurrencyCode; } public String getAdjustmentType() { return adjustmentType; } public void setAdjustmentType(String adjustmentType) { this.adjustmentType = adjustmentType; } public String getExternalAttributionModel() { return externalAttributionModel; } public void setExternalAttributionModel(String externalAttributionModel) { this.externalAttributionModel = externalAttributionModel; } public Double getExternalAttributionCredit() { return externalAttributionCredit; } public void setExternalAttributionCredit(Double externalAttributionCredit) { this.externalAttributionCredit = externalAttributionCredit; } @Override public void processMappingsFromRowValues(RowValues values) { this.setOfflineConversion(new OfflineConversion()); MappingHelpers.convertToEntity(values, MAPPINGS, this); } @Override public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) { validatePropertyNotNull(getOfflineConversion(), "OfflineConversion"); MappingHelpers.convertToValues(this, values, MAPPINGS); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy