use of com.google.api.ads.adwords.axis.v201809.cm.GoalOptimizedShoppingAd in project googleads-java-lib by googleads.
the class AddSmartShoppingAd method createSmartShoppingAd.
/**
* Creates a Smart Shopping ad.
*/
private static void createSmartShoppingAd(AdWordsServicesInterface adWordsServices, AdWordsSession session, long adGroupId) throws RemoteException {
AdGroupAdServiceInterface adGroupAdService = adWordsServices.get(session, AdGroupAdServiceInterface.class);
// Create a Smart Shopping ad (Goal-optimized Shopping ad).
GoalOptimizedShoppingAd smartShoppingAd = new GoalOptimizedShoppingAd();
// Create ad group ad.
AdGroupAd adGroupAd = new AdGroupAd();
adGroupAd.setAdGroupId(adGroupId);
adGroupAd.setAd(smartShoppingAd);
// Create operation.
AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
adGroupAdOperation.setOperand(adGroupAd);
adGroupAdOperation.setOperator(Operator.ADD);
// Make the mutate request.
AdGroupAdReturnValue adGroupAdAddResult = adGroupAdService.mutate(new AdGroupAdOperation[] { adGroupAdOperation });
// Display result.
adGroupAd = adGroupAdAddResult.getValue(0);
System.out.printf("Smart Shopping ad with ID %d was added.%n", adGroupAd.getAd().getId());
}
Aggregations