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

com.microsoft.bingads.v13.bulk.entities.BulkAdGroupHotelCheckInDateCriterion 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.Criterion;
import com.microsoft.bingads.v13.campaignmanagement.HotelCheckInDateCriterion;
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;

/**
 * Represents a HotelCheckInDateCriterion that is assigned to an ad group. Each HotelCheckInDateCriterion criterion can
 * be read or written in a bulk file.
 *
 * 

* For more information, see Ad Group HotelCheckInDateCriterion at () { @Override public void accept(String v, BulkAdGroupHotelCheckInDateCriterion c) { if (c.getBiddableAdGroupCriterion().getCriterion() instanceof HotelCheckInDateCriterion) { ((HotelCheckInDateCriterion) c.getBiddableAdGroupCriterion().getCriterion()) .setStartDate(StringExtensions.parseOptional(v, new Function() { @Override public Calendar apply(String t) { Calendar c = new GregorianCalendar(); try { SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd 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.MaxTargetValue, new Function() { @Override public String apply(BulkAdGroupHotelCheckInDateCriterion c) { if (c.getBiddableAdGroupCriterion().getCriterion() instanceof HotelCheckInDateCriterion) { HotelCheckInDateCriterion criterion = ((HotelCheckInDateCriterion) c.getBiddableAdGroupCriterion().getCriterion()); if (criterion == null || criterion.getEndDate() == null) { return null; } SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("UTC")); return format.format(criterion.getEndDate().getTime()); } return null; } }, new BiConsumer() { @Override public void accept(String v, BulkAdGroupHotelCheckInDateCriterion c) { if (c.getBiddableAdGroupCriterion().getCriterion() instanceof HotelCheckInDateCriterion) { ((HotelCheckInDateCriterion) c.getBiddableAdGroupCriterion().getCriterion()) .setEndDate(StringExtensions.parseOptional(v, new Function() { @Override public Calendar apply(String t) { Calendar c = new GregorianCalendar(); try { SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("UTC")); c.setTime(format.parse(t)); } catch (ParseException ex) { throw new UncheckedParseException(ex); } return c; } })); } } })); MAPPINGS = Collections.unmodifiableList(m); } @Override public void processMappingsFromRowValues(RowValues values) { super.processMappingsFromRowValues(values); MappingHelpers.convertToEntity(values, MAPPINGS, this); } @Override public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) { super.processMappingsToRowValues(values, excludeReadonlyData); MappingHelpers.convertToValues(this, values, MAPPINGS); } @Override protected Criterion createCriterion() { return new HotelCheckInDateCriterion(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy