Search in sources :

Example 6 with TrafficForecastSegment

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

the class GetAllTrafficForecastSegments 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) throws RemoteException {
    // Get the AdjustmentService.
    AdjustmentServiceInterface adjustmentService = adManagerServices.get(session, AdjustmentServiceInterface.class);
    // Create a statement to get all traffic forecast segments.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get traffic forecast segments by statement.
        TrafficForecastSegmentPage page = adjustmentService.getTrafficForecastSegmentsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (TrafficForecastSegment trafficForecastSegment : page.getResults()) {
                System.out.printf("%d) Traffic forecast segment with ID %d and name '%s' was found.%n", i++, trafficForecastSegment.getId(), trafficForecastSegment.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : TrafficForecastSegment(com.google.api.ads.admanager.axis.v202202.TrafficForecastSegment) TrafficForecastSegmentPage(com.google.api.ads.admanager.axis.v202202.TrafficForecastSegmentPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) AdjustmentServiceInterface(com.google.api.ads.admanager.axis.v202202.AdjustmentServiceInterface)

Aggregations

Random (java.util.Random)3 AdjustmentServiceInterface (com.google.api.ads.admanager.axis.v202108.AdjustmentServiceInterface)2 TrafficForecastSegment (com.google.api.ads.admanager.axis.v202108.TrafficForecastSegment)2 AdjustmentServiceInterface (com.google.api.ads.admanager.axis.v202111.AdjustmentServiceInterface)2 TrafficForecastSegment (com.google.api.ads.admanager.axis.v202111.TrafficForecastSegment)2 AdjustmentServiceInterface (com.google.api.ads.admanager.axis.v202202.AdjustmentServiceInterface)2 TrafficForecastSegment (com.google.api.ads.admanager.axis.v202202.TrafficForecastSegment)2 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)1 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)1 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)1 AdUnitTargeting (com.google.api.ads.admanager.axis.v202108.AdUnitTargeting)1 GeoTargeting (com.google.api.ads.admanager.axis.v202108.GeoTargeting)1 InventoryTargeting (com.google.api.ads.admanager.axis.v202108.InventoryTargeting)1 Location (com.google.api.ads.admanager.axis.v202108.Location)1 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202108.NetworkServiceInterface)1 Targeting (com.google.api.ads.admanager.axis.v202108.Targeting)1 TrafficForecastSegmentPage (com.google.api.ads.admanager.axis.v202108.TrafficForecastSegmentPage)1 AdUnitTargeting (com.google.api.ads.admanager.axis.v202111.AdUnitTargeting)1 GeoTargeting (com.google.api.ads.admanager.axis.v202111.GeoTargeting)1 InventoryTargeting (com.google.api.ads.admanager.axis.v202111.InventoryTargeting)1