private static final String LABEL_ID = "INSERT_CREATIVE_WRAPPER_LABEL_ID_HERE";
public static void runExample(DfpServices dfpServices, DfpSession session, long labelId)
throws Exception {
// Get the CreativeWrapperService.
CreativeWrapperServiceInterface creativeWrapperService =
dfpServices.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.setHeader(
new CreativeWrapperHtmlSnippet("<b>My creative wrapper header</b>"));
innerCreativeWrapper.setFooter(
new CreativeWrapperHtmlSnippet("<b>My creative wrapper footer</b>"));
// Create the creative wrappers on the server.
CreativeWrapper[] creativeWrappers =
creativeWrapperService.createCreativeWrappers(new CreativeWrapper[] {innerCreativeWrapper});
for (CreativeWrapper creativeWrapper : creativeWrappers) {
System.out.printf(
"Creative wrapper with ID \"%d\" applying to label \"%s\" was created.\n",
creativeWrapper.getId(), creativeWrapper.getLabelId());