Search in sources :

Example 1 with TargetingPresetPage

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

the class GetAllTargetingPresets 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 TargetingPresetService.
    TargetingPresetServiceInterface targetingPresetService = adManagerServices.get(session, TargetingPresetServiceInterface.class);
    // Create a statement to get all targeting presets.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get targeting presets by statement.
        TargetingPresetPage page = targetingPresetService.getTargetingPresetsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (TargetingPreset targetingPreset : page.getResults()) {
                System.out.printf("%d) Targeting preset with ID %d and name '%s' was found.%n", i++, targetingPreset.getId(), targetingPreset.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : TargetingPresetServiceInterface(com.google.api.ads.admanager.axis.v202111.TargetingPresetServiceInterface) TargetingPresetPage(com.google.api.ads.admanager.axis.v202111.TargetingPresetPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) TargetingPreset(com.google.api.ads.admanager.axis.v202111.TargetingPreset)

Example 2 with TargetingPresetPage

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

the class GetAllTargetingPresets 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 TargetingPresetService.
    TargetingPresetServiceInterface targetingPresetService = adManagerServices.get(session, TargetingPresetServiceInterface.class);
    // Create a statement to get all targeting presets.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get targeting presets by statement.
        TargetingPresetPage page = targetingPresetService.getTargetingPresetsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (TargetingPreset targetingPreset : page.getResults()) {
                System.out.printf("%d) Targeting preset with ID %d and name '%s' was found.%n", i++, targetingPreset.getId(), targetingPreset.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : TargetingPresetServiceInterface(com.google.api.ads.admanager.axis.v202108.TargetingPresetServiceInterface) TargetingPresetPage(com.google.api.ads.admanager.axis.v202108.TargetingPresetPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) TargetingPreset(com.google.api.ads.admanager.axis.v202108.TargetingPreset)

Example 3 with TargetingPresetPage

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

the class GetAllTargetingPresets 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 TargetingPresetService.
    TargetingPresetServiceInterface targetingPresetService = adManagerServices.get(session, TargetingPresetServiceInterface.class);
    // Create a statement to get all targeting presets.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get targeting presets by statement.
        TargetingPresetPage page = targetingPresetService.getTargetingPresetsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (TargetingPreset targetingPreset : page.getResults()) {
                System.out.printf("%d) Targeting preset with ID %d and name '%s' was found.%n", i++, targetingPreset.getId(), targetingPreset.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : TargetingPresetServiceInterface(com.google.api.ads.admanager.axis.v202202.TargetingPresetServiceInterface) TargetingPresetPage(com.google.api.ads.admanager.axis.v202202.TargetingPresetPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) TargetingPreset(com.google.api.ads.admanager.axis.v202202.TargetingPreset)

Aggregations

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 TargetingPreset (com.google.api.ads.admanager.axis.v202108.TargetingPreset)1 TargetingPresetPage (com.google.api.ads.admanager.axis.v202108.TargetingPresetPage)1 TargetingPresetServiceInterface (com.google.api.ads.admanager.axis.v202108.TargetingPresetServiceInterface)1 TargetingPreset (com.google.api.ads.admanager.axis.v202111.TargetingPreset)1 TargetingPresetPage (com.google.api.ads.admanager.axis.v202111.TargetingPresetPage)1 TargetingPresetServiceInterface (com.google.api.ads.admanager.axis.v202111.TargetingPresetServiceInterface)1 TargetingPreset (com.google.api.ads.admanager.axis.v202202.TargetingPreset)1 TargetingPresetPage (com.google.api.ads.admanager.axis.v202202.TargetingPresetPage)1 TargetingPresetServiceInterface (com.google.api.ads.admanager.axis.v202202.TargetingPresetServiceInterface)1