Search in sources :

Example 41 with Creative

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

Example 42 with Creative

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

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

Example 43 with Creative

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

the class CreateCreativeSets method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param masterCreativeId the ID of the master creative in the creative set.
 * @param companionCreativeId the ID of the companion creative in the creative set.
 * @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 masterCreativeId, long companionCreativeId) throws RemoteException {
    // Get the CreativeSetService.
    CreativeSetServiceInterface creativeSetService = adManagerServices.get(session, CreativeSetServiceInterface.class);
    CreativeSet creativeSet = new CreativeSet();
    creativeSet.setName("Creative set #" + new Random().nextInt(Integer.MAX_VALUE));
    creativeSet.setMasterCreativeId(masterCreativeId);
    creativeSet.setCompanionCreativeIds(new long[] { companionCreativeId });
    // Create the creative set on the server.
    CreativeSet createdCreativeSet = creativeSetService.createCreativeSet(creativeSet);
    System.out.printf("A creative set with ID %d, master creative ID %d, " + "and companion creative IDs [%s] was created.%n", createdCreativeSet.getId(), createdCreativeSet.getMasterCreativeId(), Longs.join(",", createdCreativeSet.getCompanionCreativeIds()));
}
Also used : Random(java.util.Random) CreativeSet(com.google.api.ads.admanager.axis.v202111.CreativeSet) CreativeSetServiceInterface(com.google.api.ads.admanager.axis.v202111.CreativeSetServiceInterface)

Example 44 with Creative

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

the class GetCreativeSetsForMasterCreative method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param masterCreativeId the ID of the master creative.
 * @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 masterCreativeId) throws RemoteException {
    CreativeSetServiceInterface creativeSetService = adManagerServices.get(session, CreativeSetServiceInterface.class);
    // Create a statement to select creative sets.
    StatementBuilder statementBuilder = new StatementBuilder().where("masterCreativeId = :masterCreativeId").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("masterCreativeId", masterCreativeId);
    // Retrieve a small amount of creative sets at a time, paging through
    // until all creative sets have been retrieved.
    int totalResultSetSize = 0;
    do {
        CreativeSetPage page = creativeSetService.getCreativeSetsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each creative set.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CreativeSet creativeSet : page.getResults()) {
                System.out.printf("%d) Creative set with ID %d and name '%s' was found.%n", i++, creativeSet.getId(), creativeSet.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) CreativeSetPage(com.google.api.ads.admanager.axis.v202111.CreativeSetPage) CreativeSet(com.google.api.ads.admanager.axis.v202111.CreativeSet) CreativeSetServiceInterface(com.google.api.ads.admanager.axis.v202111.CreativeSetServiceInterface)

Example 45 with Creative

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

Aggregations

Random (java.util.Random)19 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)18 Size (com.google.api.ads.admanager.axis.v202111.Size)11 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.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 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociationServiceInterface)6 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 AdUnitTargeting (com.google.api.ads.admanager.axis.v202111.AdUnitTargeting)5 CreativeAsset (com.google.api.ads.admanager.axis.v202111.CreativeAsset)5 CreativePlaceholder (com.google.api.ads.admanager.axis.v202111.CreativePlaceholder)5 CreativeWrapper (com.google.api.ads.admanager.axis.v202111.CreativeWrapper)5 CreativeWrapperServiceInterface (com.google.api.ads.admanager.axis.v202111.CreativeWrapperServiceInterface)5 Goal (com.google.api.ads.admanager.axis.v202111.Goal)5 InventoryTargeting (com.google.api.ads.admanager.axis.v202111.InventoryTargeting)5