Search in sources :

Example 1 with CreativeWrapper

use of com.google.api.ads.admanager.axis.v202111.CreativeWrapper 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 CreativeWrapper

use of com.google.api.ads.admanager.axis.v202111.CreativeWrapper 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 CreativeWrapper

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

the class CreateCreativeWrappers method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param labelId the ID of the label that can be associated with creative wrappers.
 * @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 creative wrapper.
    CreativeWrapper innerCreativeWrapper = new CreativeWrapper();
    // A label can only be associated with one creative wrapper.
    innerCreativeWrapper.setLabelId(labelId);
    innerCreativeWrapper.setOrdering(CreativeWrapperOrdering.INNER);
    innerCreativeWrapper.setHtmlHeader("<b>My creative wrapper header</b>");
    innerCreativeWrapper.setHtmlFooter("<b>My creative wrapper footer</b>");
    // Create the creative wrapper on the server.
    CreativeWrapper[] creativeWrappers = creativeWrapperService.createCreativeWrappers(new CreativeWrapper[] { innerCreativeWrapper });
    for (CreativeWrapper createdCreativeWrapper : creativeWrappers) {
        System.out.printf("Creative wrapper with ID %d applying to label ID %d was created.%n", createdCreativeWrapper.getId(), createdCreativeWrapper.getLabelId());
    }
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202108.CreativeWrapper) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202108.CreativeWrapperServiceInterface)

Example 4 with CreativeWrapper

use of com.google.api.ads.admanager.axis.v202111.CreativeWrapper 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 5 with CreativeWrapper

use of com.google.api.ads.admanager.axis.v202111.CreativeWrapper 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)

Aggregations

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