Search in sources :

Example 1 with CreativeWrapperPage

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

the class GetActiveCreativeWrappers 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 {
    CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
    // Create a statement to select creative wrappers.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", CreativeWrapperStatus.ACTIVE.toString());
    // Retrieve a small amount of creative wrappers at a time, paging through
    // until all creative wrappers have been retrieved.
    int totalResultSetSize = 0;
    do {
        CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each creative wrapper.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CreativeWrapper creativeWrapper : page.getResults()) {
                System.out.printf("%d) Creative wrapper with ID %d and label ID %d was found.%n", i++, creativeWrapper.getId(), creativeWrapper.getLabelId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202111.CreativeWrapper) CreativeWrapperPage(com.google.api.ads.admanager.axis.v202111.CreativeWrapperPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202111.CreativeWrapperServiceInterface)

Example 2 with CreativeWrapperPage

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

the class UpdateCreativeWrappers method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param creativeWrapperId the ID of the creative wrapper 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 creativeWrapperId) throws RemoteException {
    // Get the CreativeWrapperService.
    CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
    // Create a statement to only select a single creative wrapper by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeWrapperId);
    // Get the creative wrapper.
    CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
    CreativeWrapper creativeWrapper = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the creative wrapper ordering.
    creativeWrapper.setOrdering(CreativeWrapperOrdering.OUTER);
    // Update the creative wrapper on the server.
    CreativeWrapper[] creativeWrappers = creativeWrapperService.updateCreativeWrappers(new CreativeWrapper[] { creativeWrapper });
    for (CreativeWrapper updatedCreativeWrapper : creativeWrappers) {
        System.out.printf("Creative wrapper with ID %d and wrapping order '%s' was updated.%n", updatedCreativeWrapper.getId(), updatedCreativeWrapper.getOrdering());
    }
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202111.CreativeWrapper) CreativeWrapperPage(com.google.api.ads.admanager.axis.v202111.CreativeWrapperPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202111.CreativeWrapperServiceInterface)

Example 3 with CreativeWrapperPage

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

the class GetActiveCreativeWrappers 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 {
    CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
    // Create a statement to select creative wrappers.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", CreativeWrapperStatus.ACTIVE.toString());
    // Retrieve a small amount of creative wrappers at a time, paging through
    // until all creative wrappers have been retrieved.
    int totalResultSetSize = 0;
    do {
        CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each creative wrapper.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CreativeWrapper creativeWrapper : page.getResults()) {
                System.out.printf("%d) Creative wrapper with ID %d and label ID %d was found.%n", i++, creativeWrapper.getId(), creativeWrapper.getLabelId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202108.CreativeWrapper) CreativeWrapperPage(com.google.api.ads.admanager.axis.v202108.CreativeWrapperPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202108.CreativeWrapperServiceInterface)

Example 4 with CreativeWrapperPage

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

the class UpdateCreativeWrappers method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param creativeWrapperId the ID of the creative wrapper 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 creativeWrapperId) throws RemoteException {
    // Get the CreativeWrapperService.
    CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
    // Create a statement to only select a single creative wrapper by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeWrapperId);
    // Get the creative wrapper.
    CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
    CreativeWrapper creativeWrapper = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the creative wrapper ordering.
    creativeWrapper.setOrdering(CreativeWrapperOrdering.OUTER);
    // Update the creative wrapper on the server.
    CreativeWrapper[] creativeWrappers = creativeWrapperService.updateCreativeWrappers(new CreativeWrapper[] { creativeWrapper });
    for (CreativeWrapper updatedCreativeWrapper : creativeWrappers) {
        System.out.printf("Creative wrapper with ID %d and wrapping order '%s' was updated.%n", updatedCreativeWrapper.getId(), updatedCreativeWrapper.getOrdering());
    }
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202108.CreativeWrapper) CreativeWrapperPage(com.google.api.ads.admanager.axis.v202108.CreativeWrapperPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202108.CreativeWrapperServiceInterface)

Example 5 with CreativeWrapperPage

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

the class DeactivateCreativeWrappersForLabel method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param labelId the ID of the creative wrapper label to deactivate.
 * @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 labelId) throws RemoteException {
    // Get the CreativeWrapperService.
    CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
    // Create a statement to select the active creative wrappers for the
    // given label.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE status = :status AND labelId = :labelId").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", CreativeWrapperStatus.ACTIVE.toString()).withBindVariableValue("labelId", labelId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get creative wrappers by statement.
        CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CreativeWrapper creativeWrapper : page.getResults()) {
                System.out.printf("%d) Creative wrapper with ID %d applying to label ID" + " %d will be deactivated.%n", i++, creativeWrapper.getId(), creativeWrapper.getLabelId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of creative wrappers to be deactivated: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        DeactivateCreativeWrappers action = new DeactivateCreativeWrappers();
        // Perform action.
        UpdateResult result = creativeWrapperService.performCreativeWrapperAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of creative wrappers deactivated: %d%n", result.getNumChanges());
        } else {
            System.out.println("No creative wrappers were deactivated.");
        }
    }
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202202.CreativeWrapper) CreativeWrapperPage(com.google.api.ads.admanager.axis.v202202.CreativeWrapperPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) DeactivateCreativeWrappers(com.google.api.ads.admanager.axis.v202202.DeactivateCreativeWrappers) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202202.CreativeWrapperServiceInterface) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

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 CreativeWrapper (com.google.api.ads.admanager.axis.v202108.CreativeWrapper)4 CreativeWrapperPage (com.google.api.ads.admanager.axis.v202108.CreativeWrapperPage)4 CreativeWrapperServiceInterface (com.google.api.ads.admanager.axis.v202108.CreativeWrapperServiceInterface)4 CreativeWrapper (com.google.api.ads.admanager.axis.v202111.CreativeWrapper)4 CreativeWrapperPage (com.google.api.ads.admanager.axis.v202111.CreativeWrapperPage)4 CreativeWrapperServiceInterface (com.google.api.ads.admanager.axis.v202111.CreativeWrapperServiceInterface)4 CreativeWrapper (com.google.api.ads.admanager.axis.v202202.CreativeWrapper)4 CreativeWrapperPage (com.google.api.ads.admanager.axis.v202202.CreativeWrapperPage)4 CreativeWrapperServiceInterface (com.google.api.ads.admanager.axis.v202202.CreativeWrapperServiceInterface)4 DeactivateCreativeWrappers (com.google.api.ads.admanager.axis.v202108.DeactivateCreativeWrappers)1 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1 DeactivateCreativeWrappers (com.google.api.ads.admanager.axis.v202111.DeactivateCreativeWrappers)1 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)1 DeactivateCreativeWrappers (com.google.api.ads.admanager.axis.v202202.DeactivateCreativeWrappers)1 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)1