use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation in project googleads-java-lib by googleads.
the class AddDynamicPageFeed method createFeedItems.
/**
* Creates the page URLs in the DSA page feed.
*/
private static void createFeedItems(AdWordsServicesInterface adWordsServices, AdWordsSession session, DSAFeedDetails feedDetails, String labelName) throws RemoteException {
// Get the FeedItemService.
FeedItemServiceInterface feedItemService = adWordsServices.get(session, FeedItemServiceInterface.class);
// Create operations to add FeedItems.
FeedItemOperation[] operations = new FeedItemOperation[] { createDsaUrlAddOperation(feedDetails, "http://www.example.com/discounts/rental-cars", labelName), createDsaUrlAddOperation(feedDetails, "http://www.example.com/discounts/hotel-deals", labelName), createDsaUrlAddOperation(feedDetails, "http://www.example.com/discounts/flight-deals", labelName) };
FeedItemReturnValue result = feedItemService.mutate(operations);
for (FeedItem item : result.getValue()) {
System.out.printf("Feed item with feed item ID %d was added.%n", item.getFeedItemId());
}
}
use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation in project googleads-java-lib by googleads.
the class MigrateToExtensionSettings method deleteOldFeedItems.
/**
* Deletes the old feed items for which extension settings have been created.
*/
private static void deleteOldFeedItems(AdWordsServicesInterface adWordsServices, AdWordsSession session, Set<Long> feedItemIds, Feed feed) throws RemoteException {
// Get the FeedItemService.
FeedItemServiceInterface feedItemService = adWordsServices.get(session, FeedItemServiceInterface.class);
if (feedItemIds.isEmpty()) {
return;
}
List<FeedItemOperation> operations = new ArrayList<>();
for (Long feedItemId : feedItemIds) {
FeedItemOperation operation = new FeedItemOperation();
FeedItem feedItem = new FeedItem();
feedItem.setFeedId(feed.getId());
feedItem.setFeedItemId(feedItemId);
operation.setOperand(feedItem);
operation.setOperator(Operator.REMOVE);
operations.add(operation);
}
feedItemService.mutate(operations.toArray(new FeedItemOperation[operations.size()]));
}
Aggregations