Search in sources :

Example 1 with CampaignFeedPage

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

the class MigrateToExtensionSettings method getCampaignFeeds.

/**
 * Returns the campaign feeds that use a particular feed for a particular placeholder type.
 */
private static List<CampaignFeed> getCampaignFeeds(AdWordsServicesInterface adWordsServices, AdWordsSession session, Feed feed, int placeholderType) throws RemoteException {
    // Get the CampaignFeedService.
    CampaignFeedServiceInterface campaignFeedService = adWordsServices.get(session, CampaignFeedServiceInterface.class);
    String query = String.format("SELECT CampaignId, MatchingFunction, PlaceholderTypes WHERE Status = 'ENABLED' " + "AND FeedId = %d AND PlaceholderTypes CONTAINS_ANY [%d]", feed.getId(), placeholderType);
    List<CampaignFeed> campaignFeeds = new ArrayList<>();
    int offset = 0;
    CampaignFeedPage campaignFeedPage;
    do {
        String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
        campaignFeedPage = campaignFeedService.query(pageQuery);
        if (campaignFeedPage.getEntries() != null) {
            campaignFeeds.addAll(Arrays.asList(campaignFeedPage.getEntries()));
        }
        offset += PAGE_SIZE;
    } while (offset < campaignFeedPage.getTotalNumEntries());
    return campaignFeeds;
}
Also used : CampaignFeedServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedServiceInterface) CampaignFeed(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeed) CampaignFeedPage(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedPage) ArrayList(java.util.ArrayList)

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 ArrayList (java.util.ArrayList)1