Search in sources :

Example 56 with Creative

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

Example 57 with Creative

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

the class GetLicasForLineItem method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param lineItemId the ID of the line item.
 * @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 lineItemId) throws RemoteException {
    LineItemCreativeAssociationServiceInterface lineItemCreativeAssociationService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
    // Create a statement to select line item creative associations.
    StatementBuilder statementBuilder = new StatementBuilder().where("lineItemId = :lineItemId").orderBy("lineItemId ASC, creativeId ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("lineItemId", lineItemId);
    // Retrieve a small amount of line item creative associations at a time, paging through
    // until all line item creative associations have been retrieved.
    int totalResultSetSize = 0;
    do {
        LineItemCreativeAssociationPage page = lineItemCreativeAssociationService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each line item creative association.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (LineItemCreativeAssociation lica : page.getResults()) {
                if (lica.getCreativeSetId() != null) {
                    System.out.printf("%d) LICA with line item ID %d and creative set ID %d was found.%n", i++, lica.getLineItemId(), lica.getCreativeSetId());
                } else {
                    System.out.printf("%d) LICA with line item ID %d and creative ID %d was found.%n", i++, lica.getLineItemId(), lica.getCreativeId());
                }
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : LineItemCreativeAssociation(com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationPage) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationServiceInterface)

Aggregations

Random (java.util.Random)24 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)18 Size (com.google.api.ads.admanager.axis.v202205.Size)12 Creative (com.google.api.ads.admanager.axis.v202202.Creative)9 CreativeServiceInterface (com.google.api.ads.admanager.axis.v202202.CreativeServiceInterface)9 Creative (com.google.api.ads.admanager.axis.v202205.Creative)9 CreativeServiceInterface (com.google.api.ads.admanager.axis.v202205.CreativeServiceInterface)9 Creative (com.google.api.ads.admanager.axis.v202108.Creative)8 CreativeServiceInterface (com.google.api.ads.admanager.axis.v202108.CreativeServiceInterface)8 Creative (com.google.api.ads.admanager.axis.v202111.Creative)8 CreativeServiceInterface (com.google.api.ads.admanager.axis.v202111.CreativeServiceInterface)8 Size (com.google.api.ads.admanager.axis.v202202.Size)6 CreativeAsset (com.google.api.ads.admanager.axis.v202108.CreativeAsset)5 Size (com.google.api.ads.admanager.axis.v202108.Size)5 CreativeAsset (com.google.api.ads.admanager.axis.v202111.CreativeAsset)5 Size (com.google.api.ads.admanager.axis.v202111.Size)5 CreativeAsset (com.google.api.ads.admanager.axis.v202202.CreativeAsset)5 AdUnitTargeting (com.google.api.ads.admanager.axis.v202205.AdUnitTargeting)5 CreativePlaceholder (com.google.api.ads.admanager.axis.v202205.CreativePlaceholder)5 Goal (com.google.api.ads.admanager.axis.v202205.Goal)5