Search in sources :

Example 1 with FeedPage

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

the class MigrateToExtensionSettings method getFeeds.

/**
 * Returns a list of all enabled feeds.
 */
private static List<Feed> getFeeds(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
    String query = "SELECT Id, Name, Attributes WHERE Origin = 'USER' AND FeedStatus = 'ENABLED'";
    List<Feed> feeds = new ArrayList<>();
    int offset = 0;
    FeedPage feedPage;
    do {
        String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
        feedPage = feedService.query(pageQuery);
        if (feedPage.getEntries() != null) {
            feeds.addAll(Arrays.asList(feedPage.getEntries()));
        }
        offset += PAGE_SIZE;
    } while (offset < feedPage.getTotalNumEntries());
    return feeds;
}
Also used : FeedPage(com.google.api.ads.adwords.axis.v201809.cm.FeedPage) CampaignFeedPage(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedPage) CampaignFeedServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedServiceInterface) FeedServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedServiceInterface) ArrayList(java.util.ArrayList) CampaignFeed(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeed) Feed(com.google.api.ads.adwords.axis.v201809.cm.Feed)

Aggregations

CampaignFeed (com.google.api.ads.adwords.axis.v201809.cm.CampaignFeed)1 CampaignFeedPage (com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedPage)1 CampaignFeedServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedServiceInterface)1 Feed (com.google.api.ads.adwords.axis.v201809.cm.Feed)1 FeedPage (com.google.api.ads.adwords.axis.v201809.cm.FeedPage)1 FeedServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.FeedServiceInterface)1 ArrayList (java.util.ArrayList)1