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());
}
}
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);
}
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()));
}
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);
}
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);
}
Aggregations