use of com.google.api.ads.adwords.axis.v201809.cm.FeedItem 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()]));
}
use of com.google.api.ads.adwords.axis.v201809.cm.FeedItem in project googleads-java-lib by googleads.
the class AddSiteLinksUsingFeeds method restrictFeedItemToGeoTarget.
/**
* Restricts the first feed item in {@code siteLinksData} to only serve with ads for the specified
* location ID.
*/
private static void restrictFeedItemToGeoTarget(AdWordsServicesInterface adWordsServices, AdWordsSession session, FeedItem feedItem, Long locationId) throws RemoteException {
FeedItemTargetServiceInterface feedItemTargetService = adWordsServices.get(session, FeedItemTargetServiceInterface.class);
// Optional: Restrict the feed item to only serve with ads for the specified geo target.
FeedItemCriterionTarget feedItemCriterionTarget = new FeedItemCriterionTarget();
feedItemCriterionTarget.setFeedId(feedItem.getFeedId());
feedItemCriterionTarget.setFeedItemId(feedItem.getFeedItemId());
Location location = new Location();
// The IDs can be found in the documentation or retrieved with the LocationCriterionService.
location.setId(locationId);
feedItemCriterionTarget.setCriterion(location);
FeedItemTargetOperation operation = new FeedItemTargetOperation();
operation.setOperand(feedItemCriterionTarget);
operation.setOperator(Operator.ADD);
feedItemCriterionTarget = (FeedItemCriterionTarget) feedItemTargetService.mutate(new FeedItemTargetOperation[] { operation }).getValue(0);
System.out.printf("Feed item target for feed ID %d and feed item ID %d was created to restrict serving to " + "location ID %d'.%n", feedItemCriterionTarget.getFeedId(), feedItemCriterionTarget.getFeedItemId(), feedItemCriterionTarget.getCriterion().getId());
}
Aggregations