// Get the CreativeTemplateService.
CreativeTemplateServiceInterface creativeTemplateService =
user.getService(DfpService.V201306.CREATIVE_TEMPLATE_SERVICE);
// Set defaults for page and filterStatement.
CreativeTemplatePage page = new CreativeTemplatePage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all creative templates.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get creative templates by statement.
page = creativeTemplateService.getCreativeTemplatesByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (CreativeTemplate creativeTemplate : page.getResults()) {
System.out.println(i + ") Creative template with ID \"" + creativeTemplate.getId()
+ "\", name \"" + creativeTemplate.getName()
+ "\", and type \"" + creativeTemplate.getType() + "\" was found.");
i++;
}
}
offset += 500;
} while (offset < page.getTotalResultSetSize());
System.out.println("Number of results found: " + page.getTotalResultSetSize());
} catch (Exception e) {
e.printStackTrace();
}
}