Search in sources :

Example 16 with PlacementPage

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

the class GetAllPlacements 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 PlacementService.
    PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
    // Create a statement to get all placements.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get placements by statement.
        PlacementPage page = placementService.getPlacementsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Placement placement : page.getResults()) {
                System.out.printf("%d) Placement with ID %d and name '%s' was found.%n", i++, placement.getId(), placement.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202205.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202205.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202205.PlacementServiceInterface)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)4 Placement (com.google.api.ads.admanager.axis.v202108.Placement)4 PlacementPage (com.google.api.ads.admanager.axis.v202108.PlacementPage)4 PlacementServiceInterface (com.google.api.ads.admanager.axis.v202108.PlacementServiceInterface)4 Placement (com.google.api.ads.admanager.axis.v202111.Placement)4 PlacementPage (com.google.api.ads.admanager.axis.v202111.PlacementPage)4 PlacementServiceInterface (com.google.api.ads.admanager.axis.v202111.PlacementServiceInterface)4 Placement (com.google.api.ads.admanager.axis.v202202.Placement)4 PlacementPage (com.google.api.ads.admanager.axis.v202202.PlacementPage)4 PlacementServiceInterface (com.google.api.ads.admanager.axis.v202202.PlacementServiceInterface)4 Placement (com.google.api.ads.admanager.axis.v202205.Placement)4 PlacementPage (com.google.api.ads.admanager.axis.v202205.PlacementPage)4 PlacementServiceInterface (com.google.api.ads.admanager.axis.v202205.PlacementServiceInterface)4 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)1