Search in sources :

Example 1 with FeedItemPage

use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemPage in project googleads-java-lib by googleads.

the class MigrateToExtensionSettings method getFeedItems.

/**
 * Returns the feed items for a feed.
 */
private static List<FeedItem> getFeedItems(AdWordsServicesInterface adWordsServices, AdWordsSession session, Feed feed) throws RemoteException {
    // Get the FeedItemService.
    FeedItemServiceInterface feedItemService = adWordsServices.get(session, FeedItemServiceInterface.class);
    String query = String.format("SELECT FeedItemId, AttributeValues WHERE Status = 'ENABLED' AND FeedId = %d", feed.getId());
    List<FeedItem> feedItems = new ArrayList<>();
    int offset = 0;
    FeedItemPage feedItemPage;
    do {
        String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
        feedItemPage = feedItemService.query(pageQuery);
        if (feedItemPage.getEntries() != null) {
            feedItems.addAll(Arrays.asList(feedItemPage.getEntries()));
        }
        offset += PAGE_SIZE;
    } while (offset < feedItemPage.getTotalNumEntries());
    return feedItems;
}
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) FeedItemPage(com.google.api.ads.adwords.axis.v201809.cm.FeedItemPage)

Aggregations

ExtensionFeedItem (com.google.api.ads.adwords.axis.v201809.cm.ExtensionFeedItem)1 FeedItem (com.google.api.ads.adwords.axis.v201809.cm.FeedItem)1 FeedItemPage (com.google.api.ads.adwords.axis.v201809.cm.FeedItemPage)1 FeedItemServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.FeedItemServiceInterface)1 SitelinkFeedItem (com.google.api.ads.adwords.axis.v201809.cm.SitelinkFeedItem)1 ArrayList (java.util.ArrayList)1