Search in sources :

Example 1 with FeedItemTargetReturnValue

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

the class AddAdCustomizer method restrictFeedItemToAdGroup.

/**
 * Restricts the feed item to an ad group.
 */
private static void restrictFeedItemToAdGroup(AdWordsServicesInterface adWordsServices, AdWordsSession session, FeedItem feedItem, long adGroupId) throws RemoteException {
    // Get the FeedItemTargetingService.
    FeedItemTargetServiceInterface feedItemTargetService = adWordsServices.get(session, FeedItemTargetServiceInterface.class);
    FeedItemAdGroupTarget adGroupTarget = new FeedItemAdGroupTarget();
    adGroupTarget.setFeedId(feedItem.getFeedId());
    adGroupTarget.setFeedItemId(feedItem.getFeedItemId());
    adGroupTarget.setAdGroupId(adGroupId);
    FeedItemTargetOperation operation = new FeedItemTargetOperation();
    operation.setOperator(Operator.ADD);
    operation.setOperand(adGroupTarget);
    FeedItemTargetReturnValue returnValue = feedItemTargetService.mutate(new FeedItemTargetOperation[] { operation });
    FeedItemAdGroupTarget addedAdGroupTarget = (FeedItemAdGroupTarget) returnValue.getValue(0);
    System.out.printf("Feed item target for feed ID %d and feed item ID %d " + "was created to restrict serving to ad group ID %d.%n", addedAdGroupTarget.getFeedId(), addedAdGroupTarget.getFeedItemId(), addedAdGroupTarget.getAdGroupId());
}
Also used : FeedItemTargetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface) FeedItemAdGroupTarget(com.google.api.ads.adwords.axis.v201809.cm.FeedItemAdGroupTarget) FeedItemTargetReturnValue(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetReturnValue) FeedItemTargetOperation(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetOperation)

Aggregations

FeedItemAdGroupTarget (com.google.api.ads.adwords.axis.v201809.cm.FeedItemAdGroupTarget)1 FeedItemTargetOperation (com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetOperation)1 FeedItemTargetReturnValue (com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetReturnValue)1 FeedItemTargetServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface)1