use of com.google.api.ads.admanager.axis.v202111.CreativeSetPage in project googleads-java-lib by googleads.
the class UpdateCreativeSets method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param creativeSetId the ID of the creative set to update.
* @param companionCreativeId the ID of the companion creative to add to 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 creativeSetId, long companionCreativeId) throws RemoteException {
// Get the CreativeSetService.
CreativeSetServiceInterface creativeSetService = adManagerServices.get(session, CreativeSetServiceInterface.class);
// Create a statement to only select a single creative set by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeSetId);
// Get the creative set.
CreativeSetPage page = creativeSetService.getCreativeSetsByStatement(statementBuilder.toStatement());
CreativeSet creativeSet = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Add the companion creative to the creative set.
creativeSet.setCompanionCreativeIds(Longs.concat(creativeSet.getCompanionCreativeIds(), new long[] { companionCreativeId }));
// Update the creative set on the server.
CreativeSet updatedCreativeSet = creativeSetService.updateCreativeSet(creativeSet);
System.out.printf("A creative set with ID %d, master creative ID %d, " + "and companion creative IDs [%s] was updated.", updatedCreativeSet.getId(), updatedCreativeSet.getMasterCreativeId(), Longs.join(",", updatedCreativeSet.getCompanionCreativeIds()));
}
use of com.google.api.ads.admanager.axis.v202111.CreativeSetPage 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.CreativeSetPage in project googleads-java-lib by googleads.
the class GetAllCreativeSets 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 CreativeSetService.
CreativeSetServiceInterface creativeSetService = adManagerServices.get(session, CreativeSetServiceInterface.class);
// Create a statement to get all creativeSets.
StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get creative sets by statement.
CreativeSetPage page = creativeSetService.getCreativeSetsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
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.CreativeSetPage 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);
}
Aggregations