use of com.google.api.ads.admanager.axis.v202205.HistoricalBasisVolumeSettings in project googleads-java-lib by googleads.
the class CreateForecastAdjustments method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param trafficForecastSegmentId the ID of the traffic forecast segment to create the adjustment
* for.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long trafficForecastSegmentId) throws RemoteException {
// Get the adjustment service.
AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
ForecastAdjustment forecastAdjustment = new ForecastAdjustment();
forecastAdjustment.setName("Forecast adjustment #" + new Random().nextInt(Integer.MAX_VALUE));
forecastAdjustment.setTrafficForecastSegmentId(trafficForecastSegmentId);
// Set the date range that this adjustment will be applied to.
Date startDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
Date endDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
DateRange dateRange = new DateRange();
dateRange.setStartDate(startDate);
dateRange.setEndDate(endDate);
forecastAdjustment.setDateRange(dateRange);
// Set the adjustment type to be a historical basis.
forecastAdjustment.setVolumeType(ForecastAdjustmentVolumeType.HISTORICAL_BASIS_VOLUME);
HistoricalBasisVolumeSettings settings = new HistoricalBasisVolumeSettings();
settings.setUseParentTrafficForecastSegmentTargeting(true);
Date historicalStartDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
Date historicalEndDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
DateRange historicalDateRange = new DateRange();
historicalDateRange.setStartDate(historicalStartDate);
historicalDateRange.setEndDate(historicalEndDate);
settings.setHistoricalDateRange(historicalDateRange);
settings.setMultiplierMilliPercent(110000L);
forecastAdjustment.setHistoricalBasisVolumeSettings(settings);
forecastAdjustment.setStatus(ForecastAdjustmentStatus.ACTIVE);
// Update the forecast adjustment on the server.
ForecastAdjustment[] forecastAdjustments = adjustmentService.createForecastAdjustments(new ForecastAdjustment[] { forecastAdjustment });
for (ForecastAdjustment createdForecastAdjustment : forecastAdjustments) {
System.out.printf("Forecast adjustment with ID %d and name '%s' was created.%n", createdForecastAdjustment.getId(), createdForecastAdjustment.getName());
}
}
use of com.google.api.ads.admanager.axis.v202205.HistoricalBasisVolumeSettings in project googleads-java-lib by googleads.
the class CreateForecastAdjustments method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param trafficForecastSegmentId the ID of the traffic forecast segment to create the adjustment
* for.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long trafficForecastSegmentId) throws RemoteException {
// Get the adjustment service.
AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
ForecastAdjustment forecastAdjustment = new ForecastAdjustment();
forecastAdjustment.setName("Forecast adjustment #" + new Random().nextInt(Integer.MAX_VALUE));
forecastAdjustment.setTrafficForecastSegmentId(trafficForecastSegmentId);
// Set the date range that this adjustment will be applied to.
Date startDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
Date endDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
DateRange dateRange = new DateRange();
dateRange.setStartDate(startDate);
dateRange.setEndDate(endDate);
forecastAdjustment.setDateRange(dateRange);
// Set the adjustment type to be a historical basis.
forecastAdjustment.setVolumeType(ForecastAdjustmentVolumeType.HISTORICAL_BASIS_VOLUME);
HistoricalBasisVolumeSettings settings = new HistoricalBasisVolumeSettings();
settings.setUseParentTrafficForecastSegmentTargeting(true);
Date historicalStartDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
Date historicalEndDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
DateRange historicalDateRange = new DateRange();
historicalDateRange.setStartDate(historicalStartDate);
historicalDateRange.setEndDate(historicalEndDate);
settings.setHistoricalDateRange(historicalDateRange);
settings.setMultiplierMilliPercent(110000L);
forecastAdjustment.setHistoricalBasisVolumeSettings(settings);
forecastAdjustment.setStatus(ForecastAdjustmentStatus.ACTIVE);
// Update the forecast adjustment on the server.
ForecastAdjustment[] forecastAdjustments = adjustmentService.createForecastAdjustments(new ForecastAdjustment[] { forecastAdjustment });
for (ForecastAdjustment createdForecastAdjustment : forecastAdjustments) {
System.out.printf("Forecast adjustment with ID %d and name '%s' was created.%n", createdForecastAdjustment.getId(), createdForecastAdjustment.getName());
}
}
use of com.google.api.ads.admanager.axis.v202205.HistoricalBasisVolumeSettings in project googleads-java-lib by googleads.
the class CreateForecastAdjustments method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param trafficForecastSegmentId the ID of the traffic forecast segment to create the adjustment
* for.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long trafficForecastSegmentId) throws RemoteException {
// Get the adjustment service.
AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
ForecastAdjustment forecastAdjustment = new ForecastAdjustment();
forecastAdjustment.setName("Forecast adjustment #" + new Random().nextInt(Integer.MAX_VALUE));
forecastAdjustment.setTrafficForecastSegmentId(trafficForecastSegmentId);
// Set the date range that this adjustment will be applied to.
Date startDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
Date endDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
DateRange dateRange = new DateRange();
dateRange.setStartDate(startDate);
dateRange.setEndDate(endDate);
forecastAdjustment.setDateRange(dateRange);
// Set the adjustment type to be a historical basis.
forecastAdjustment.setVolumeType(ForecastAdjustmentVolumeType.HISTORICAL_BASIS_VOLUME);
HistoricalBasisVolumeSettings settings = new HistoricalBasisVolumeSettings();
settings.setUseParentTrafficForecastSegmentTargeting(true);
Date historicalStartDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
Date historicalEndDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
DateRange historicalDateRange = new DateRange();
historicalDateRange.setStartDate(historicalStartDate);
historicalDateRange.setEndDate(historicalEndDate);
settings.setHistoricalDateRange(historicalDateRange);
settings.setMultiplierMilliPercent(110000L);
forecastAdjustment.setHistoricalBasisVolumeSettings(settings);
forecastAdjustment.setStatus(ForecastAdjustmentStatus.ACTIVE);
// Update the forecast adjustment on the server.
ForecastAdjustment[] forecastAdjustments = adjustmentService.createForecastAdjustments(new ForecastAdjustment[] { forecastAdjustment });
for (ForecastAdjustment createdForecastAdjustment : forecastAdjustments) {
System.out.printf("Forecast adjustment with ID %d and name '%s' was created.%n", createdForecastAdjustment.getId(), createdForecastAdjustment.getName());
}
}
use of com.google.api.ads.admanager.axis.v202205.HistoricalBasisVolumeSettings in project googleads-java-lib by googleads.
the class CreateForecastAdjustments method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param trafficForecastSegmentId the ID of the traffic forecast segment to create the adjustment
* for.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long trafficForecastSegmentId) throws RemoteException {
// Get the adjustment service.
AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
ForecastAdjustment forecastAdjustment = new ForecastAdjustment();
forecastAdjustment.setName("Forecast adjustment #" + new Random().nextInt(Integer.MAX_VALUE));
forecastAdjustment.setTrafficForecastSegmentId(trafficForecastSegmentId);
// Set the date range that this adjustment will be applied to.
Date startDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
Date endDate = new Date(org.joda.time.DateTime.now().plusYears(1).getYear(), 1, 1);
DateRange dateRange = new DateRange();
dateRange.setStartDate(startDate);
dateRange.setEndDate(endDate);
forecastAdjustment.setDateRange(dateRange);
// Set the adjustment type to be a historical basis.
forecastAdjustment.setVolumeType(ForecastAdjustmentVolumeType.HISTORICAL_BASIS_VOLUME);
HistoricalBasisVolumeSettings settings = new HistoricalBasisVolumeSettings();
settings.setUseParentTrafficForecastSegmentTargeting(true);
Date historicalStartDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
Date historicalEndDate = new Date(org.joda.time.DateTime.now().getYear(), 1, 1);
DateRange historicalDateRange = new DateRange();
historicalDateRange.setStartDate(historicalStartDate);
historicalDateRange.setEndDate(historicalEndDate);
settings.setHistoricalDateRange(historicalDateRange);
settings.setMultiplierMilliPercent(110000L);
forecastAdjustment.setHistoricalBasisVolumeSettings(settings);
forecastAdjustment.setStatus(ForecastAdjustmentStatus.ACTIVE);
// Update the forecast adjustment on the server.
ForecastAdjustment[] forecastAdjustments = adjustmentService.createForecastAdjustments(new ForecastAdjustment[] { forecastAdjustment });
for (ForecastAdjustment createdForecastAdjustment : forecastAdjustments) {
System.out.printf("Forecast adjustment with ID %d and name '%s' was created.%n", createdForecastAdjustment.getId(), createdForecastAdjustment.getName());
}
}
Aggregations