// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the SuggestedAdUnitService.
SuggestedAdUnitServiceInterface suggestedAdUnitService =
user.getService(DfpService.V201306.SUGGESTED_AD_UNIT_SERVICE);
// Create statement to select all suggested ad units with 50 or more
// requests.
Statement filterStatement =
new StatementBuilder("WHERE numRequests >= :numRequests").putValue("numRequests", 50L)
.toStatement();
// Get suggested ad units by statement.
SuggestedAdUnitPage page =
suggestedAdUnitService.getSuggestedAdUnitsByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (SuggestedAdUnit suggestedAdUnit : page.getResults()) {
System.out.println(i + ") Suggested ad unit with ID \"" + suggestedAdUnit.getId()
+ "\" and number of requests \"" + suggestedAdUnit.getNumRequests()
+ "\" will be approved.");
i++;
}
System.out.println("Number of suggested ad units to be approved: "
+ page.getTotalResultSetSize());
// Create action.
ApproveSuggestedAdUnit action = new ApproveSuggestedAdUnit();
// Perform action.
SuggestedAdUnitUpdateResult result =
suggestedAdUnitService.performSuggestedAdUnitAction(action, filterStatement);
// Display results.
if (result != null && result.getNumChanges() > 0) {
System.out.println("Number of suggested ad units approved: " + result.getNumChanges());
} else {