Search in sources :

Example 6 with FeedItemOperation

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());
    }
}
Also used : FeedItem(com.google.api.ads.adwords.axis.v201809.cm.FeedItem) FeedItemServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedItemServiceInterface) FeedItemReturnValue(com.google.api.ads.adwords.axis.v201809.cm.FeedItemReturnValue) FeedItemOperation(com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation)

Example 7 with FeedItemOperation

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()]));
}
Also used : FeedItem(com.google.api.ads.adwords.axis.v201809.cm.FeedItem) ExtensionFeedItem(com.google.api.ads.adwords.axis.v201809.cm.ExtensionFeedItem) SitelinkFeedItem(com.google.api.ads.adwords.axis.v201809.cm.SitelinkFeedItem) FeedItemServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedItemServiceInterface) ArrayList(java.util.ArrayList) FeedItemOperation(com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation)

Aggregations

FeedItem (com.google.api.ads.adwords.axis.v201809.cm.FeedItem)7 FeedItemOperation (com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation)7 FeedItemServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.FeedItemServiceInterface)4 FeedItemAttributeValue (com.google.api.ads.adwords.axis.v201809.cm.FeedItemAttributeValue)3 FeedItemReturnValue (com.google.api.ads.adwords.axis.v201809.cm.FeedItemReturnValue)3 ArrayList (java.util.ArrayList)3 ExtensionFeedItem (com.google.api.ads.adwords.axis.v201809.cm.ExtensionFeedItem)1 FeedItemGeoRestriction (com.google.api.ads.adwords.axis.v201809.cm.FeedItemGeoRestriction)1 SitelinkFeedItem (com.google.api.ads.adwords.axis.v201809.cm.SitelinkFeedItem)1 DateTime (org.joda.time.DateTime)1