Search in sources :

Example 6 with CreativeTemplate

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

the class GetSystemDefinedCreativeTemplates 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 {
    CreativeTemplateServiceInterface creativeTemplateService = adManagerServices.get(session, CreativeTemplateServiceInterface.class);
    // Create a statement to select creative templates.
    StatementBuilder statementBuilder = new StatementBuilder().where("type = :type").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("type", CreativeTemplateType.SYSTEM_DEFINED.toString());
    // Retrieve a small amount of creative templates at a time, paging through
    // until all creative templates have been retrieved.
    int totalResultSetSize = 0;
    do {
        CreativeTemplatePage page = creativeTemplateService.getCreativeTemplatesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each creative template.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CreativeTemplate creativeTemplate : page.getResults()) {
                System.out.printf("%d) Creative template with ID %d and name '%s' was found.%n", i++, creativeTemplate.getId(), creativeTemplate.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CreativeTemplateServiceInterface(com.google.api.ads.admanager.axis.v202111.CreativeTemplateServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) CreativeTemplate(com.google.api.ads.admanager.axis.v202111.CreativeTemplate) CreativeTemplatePage(com.google.api.ads.admanager.axis.v202111.CreativeTemplatePage)

Example 7 with CreativeTemplate

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

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

Example 8 with CreativeTemplate

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

the class GetSystemDefinedCreativeTemplates 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 {
    CreativeTemplateServiceInterface creativeTemplateService = adManagerServices.get(session, CreativeTemplateServiceInterface.class);
    // Create a statement to select creative templates.
    StatementBuilder statementBuilder = new StatementBuilder().where("type = :type").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("type", CreativeTemplateType.SYSTEM_DEFINED.toString());
    // Retrieve a small amount of creative templates at a time, paging through
    // until all creative templates have been retrieved.
    int totalResultSetSize = 0;
    do {
        CreativeTemplatePage page = creativeTemplateService.getCreativeTemplatesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each creative template.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CreativeTemplate creativeTemplate : page.getResults()) {
                System.out.printf("%d) Creative template with ID %d and name '%s' was found.%n", i++, creativeTemplate.getId(), creativeTemplate.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CreativeTemplateServiceInterface(com.google.api.ads.admanager.axis.v202205.CreativeTemplateServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) CreativeTemplate(com.google.api.ads.admanager.axis.v202205.CreativeTemplate) CreativeTemplatePage(com.google.api.ads.admanager.axis.v202205.CreativeTemplatePage)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)2 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)2 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)2 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)2 CreativeTemplate (com.google.api.ads.admanager.axis.v202108.CreativeTemplate)2 CreativeTemplatePage (com.google.api.ads.admanager.axis.v202108.CreativeTemplatePage)2 CreativeTemplateServiceInterface (com.google.api.ads.admanager.axis.v202108.CreativeTemplateServiceInterface)2 CreativeTemplate (com.google.api.ads.admanager.axis.v202111.CreativeTemplate)2 CreativeTemplatePage (com.google.api.ads.admanager.axis.v202111.CreativeTemplatePage)2 CreativeTemplateServiceInterface (com.google.api.ads.admanager.axis.v202111.CreativeTemplateServiceInterface)2 CreativeTemplate (com.google.api.ads.admanager.axis.v202202.CreativeTemplate)2 CreativeTemplatePage (com.google.api.ads.admanager.axis.v202202.CreativeTemplatePage)2 CreativeTemplateServiceInterface (com.google.api.ads.admanager.axis.v202202.CreativeTemplateServiceInterface)2 CreativeTemplate (com.google.api.ads.admanager.axis.v202205.CreativeTemplate)2 CreativeTemplatePage (com.google.api.ads.admanager.axis.v202205.CreativeTemplatePage)2 CreativeTemplateServiceInterface (com.google.api.ads.admanager.axis.v202205.CreativeTemplateServiceInterface)2