Search in sources :

Example 6 with ForecastAdjustmentPage

use of com.google.api.ads.admanager.axis.v202205.ForecastAdjustmentPage in project googleads-java-lib by googleads.

the class GetForecastAdjustmentsForTrafficForecastSegment method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @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 AdjustmentService.
    AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
    // Create a statement to get all forecast adjustments.
    StatementBuilder statementBuilder = new StatementBuilder().where("trafficForecastSegmentId = :trafficForecastSegmentId").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("trafficForecastSegmentId", trafficForecastSegmentId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get forecast adjustments by statement.
        ForecastAdjustmentPage page = adjustmentService.getForecastAdjustmentsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (ForecastAdjustment adjustment : page.getResults()) {
                System.out.printf("%d) Forecast adjustment with ID %d and name '%s' belonging to the traffic forecast" + " segment %d was found.%n", i++, adjustment.getId(), adjustment.getName(), adjustment.getTrafficForecastSegmentId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ForecastAdjustmentPage(com.google.api.ads.admanager.axis.v202108.ForecastAdjustmentPage) AdjustmentServiceInterface(com.google.api.ads.admanager.axis.v202108.AdjustmentServiceInterface) ForecastAdjustment(com.google.api.ads.admanager.axis.v202108.ForecastAdjustment)

Example 7 with ForecastAdjustmentPage

use of com.google.api.ads.admanager.axis.v202205.ForecastAdjustmentPage in project googleads-java-lib by googleads.

the class UpdateForecastAdjustments method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param adjustmentId the ID of the adjustment to update.
 * @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 adjustmentId) throws RemoteException {
    // Get the adjustment service.
    AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
    // Create a statement to only select a single forecast adjustment by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", adjustmentId);
    // Get the forecast adjustment.
    ForecastAdjustmentPage page = adjustmentService.getForecastAdjustmentsByStatement(statementBuilder.toStatement());
    ForecastAdjustment adjustment = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    adjustment.setName(adjustment.getName() + " (updated)");
    // Update the forecast adjustment on the server.
    ForecastAdjustment[] adjustments = adjustmentService.updateForecastAdjustments(new ForecastAdjustment[] { adjustment });
    for (ForecastAdjustment updatedAdjustment : adjustments) {
        System.out.printf("Forecast adjustment with ID %d and name '%s' was updated.%n", updatedAdjustment.getId(), updatedAdjustment.getName());
    }
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ForecastAdjustmentPage(com.google.api.ads.admanager.axis.v202108.ForecastAdjustmentPage) AdjustmentServiceInterface(com.google.api.ads.admanager.axis.v202108.AdjustmentServiceInterface) ForecastAdjustment(com.google.api.ads.admanager.axis.v202108.ForecastAdjustment)

Example 8 with ForecastAdjustmentPage

use of com.google.api.ads.admanager.axis.v202205.ForecastAdjustmentPage in project googleads-java-lib by googleads.

the class GetForecastAdjustmentsForTrafficForecastSegment method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @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 AdjustmentService.
    AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
    // Create a statement to get all forecast adjustments.
    StatementBuilder statementBuilder = new StatementBuilder().where("trafficForecastSegmentId = :trafficForecastSegmentId").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("trafficForecastSegmentId", trafficForecastSegmentId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get forecast adjustments by statement.
        ForecastAdjustmentPage page = adjustmentService.getForecastAdjustmentsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (ForecastAdjustment adjustment : page.getResults()) {
                System.out.printf("%d) Forecast adjustment with ID %d and name '%s' belonging to the traffic forecast" + " segment %d was found.%n", i++, adjustment.getId(), adjustment.getName(), adjustment.getTrafficForecastSegmentId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) ForecastAdjustmentPage(com.google.api.ads.admanager.axis.v202111.ForecastAdjustmentPage) AdjustmentServiceInterface(com.google.api.ads.admanager.axis.v202111.AdjustmentServiceInterface) ForecastAdjustment(com.google.api.ads.admanager.axis.v202111.ForecastAdjustment)

Example 9 with ForecastAdjustmentPage

use of com.google.api.ads.admanager.axis.v202205.ForecastAdjustmentPage in project googleads-java-lib by googleads.

the class UpdateForecastAdjustments method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param adjustmentId the ID of the adjustment to update.
 * @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 adjustmentId) throws RemoteException {
    // Get the adjustment service.
    AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
    // Create a statement to only select a single forecast adjustment by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", adjustmentId);
    // Get the forecast adjustment.
    ForecastAdjustmentPage page = adjustmentService.getForecastAdjustmentsByStatement(statementBuilder.toStatement());
    ForecastAdjustment adjustment = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    adjustment.setName(adjustment.getName() + " (updated)");
    // Update the forecast adjustment on the server.
    ForecastAdjustment[] adjustments = adjustmentService.updateForecastAdjustments(new ForecastAdjustment[] { adjustment });
    for (ForecastAdjustment updatedAdjustment : adjustments) {
        System.out.printf("Forecast adjustment with ID %d and name '%s' was updated.%n", updatedAdjustment.getId(), updatedAdjustment.getName());
    }
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) ForecastAdjustmentPage(com.google.api.ads.admanager.axis.v202111.ForecastAdjustmentPage) AdjustmentServiceInterface(com.google.api.ads.admanager.axis.v202111.AdjustmentServiceInterface) ForecastAdjustment(com.google.api.ads.admanager.axis.v202111.ForecastAdjustment)

Example 10 with ForecastAdjustmentPage

use of com.google.api.ads.admanager.axis.v202205.ForecastAdjustmentPage in project googleads-java-lib by googleads.

the class GetForecastAdjustmentsForTrafficForecastSegment method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @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 AdjustmentService.
    AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
    // Create a statement to get all forecast adjustments.
    StatementBuilder statementBuilder = new StatementBuilder().where("trafficForecastSegmentId = :trafficForecastSegmentId").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("trafficForecastSegmentId", trafficForecastSegmentId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get forecast adjustments by statement.
        ForecastAdjustmentPage page = adjustmentService.getForecastAdjustmentsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (ForecastAdjustment adjustment : page.getResults()) {
                System.out.printf("%d) Forecast adjustment with ID %d and name '%s' belonging to the traffic forecast" + " segment %d was found.%n", i++, adjustment.getId(), adjustment.getName(), adjustment.getTrafficForecastSegmentId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) ForecastAdjustmentPage(com.google.api.ads.admanager.axis.v202202.ForecastAdjustmentPage) AdjustmentServiceInterface(com.google.api.ads.admanager.axis.v202202.AdjustmentServiceInterface) ForecastAdjustment(com.google.api.ads.admanager.axis.v202202.ForecastAdjustment)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)3 AdjustmentServiceInterface (com.google.api.ads.admanager.axis.v202108.AdjustmentServiceInterface)3 ForecastAdjustment (com.google.api.ads.admanager.axis.v202108.ForecastAdjustment)3 ForecastAdjustmentPage (com.google.api.ads.admanager.axis.v202108.ForecastAdjustmentPage)3 AdjustmentServiceInterface (com.google.api.ads.admanager.axis.v202111.AdjustmentServiceInterface)3 ForecastAdjustment (com.google.api.ads.admanager.axis.v202111.ForecastAdjustment)3 ForecastAdjustmentPage (com.google.api.ads.admanager.axis.v202111.ForecastAdjustmentPage)3 AdjustmentServiceInterface (com.google.api.ads.admanager.axis.v202202.AdjustmentServiceInterface)3 ForecastAdjustment (com.google.api.ads.admanager.axis.v202202.ForecastAdjustment)3 ForecastAdjustmentPage (com.google.api.ads.admanager.axis.v202202.ForecastAdjustmentPage)3 AdjustmentServiceInterface (com.google.api.ads.admanager.axis.v202205.AdjustmentServiceInterface)3 ForecastAdjustment (com.google.api.ads.admanager.axis.v202205.ForecastAdjustment)3 ForecastAdjustmentPage (com.google.api.ads.admanager.axis.v202205.ForecastAdjustmentPage)3