.build();
ExpressBusiness business = businessService.get(businessSelector).getEntries(0);
// Get the PromotionService
PromotionServiceInterface promotionService =
adWordsServices.get(session, PromotionServiceInterface.class);
// PromotionService requires the businessId on the session
session.setExpressBusinessId(businessId);
// Set up the new Promotion
Promotion marsTourPromotion = new Promotion();
Money budget = new Money();
budget.setMicroAmount(1000000L);
marsTourPromotion.setName("Mars Tour Promotion " + System.currentTimeMillis());
marsTourPromotion.setStatus(PromotionStatus.PAUSED);
marsTourPromotion.setDestinationUrl("http://www.example.com");
marsTourPromotion.setBudget(budget);
marsTourPromotion.setCallTrackingEnabled(true);
// Criteria
List<Criterion> criteria = Lists.newArrayList();
// Criterion - Travel Agency product/service. See GetProductServices.java for an example
// of how to get valid product/service settings.
ProductService productService = new ProductService();
productService.setText("Travel Agency");
productService.setLocale("en_US");
criteria.add(productService);
// Criterion - English language
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/languagecodes
Language language = new Language();
language.setId(1000L);
criteria.add(language);
// Criterion - Within 15 miles
Proximity proximity = new Proximity();
proximity.setGeoPoint(business.getGeoPoint());
proximity.setRadiusDistanceUnits(ProximityDistanceUnits.MILES);
proximity.setRadiusInUnits(15d);
criteria.add(proximity);
marsTourPromotion.setCriteria(criteria.toArray(new Criterion[criteria.size()]));
// Creatives
List<Creative> creatives = Lists.newArrayList();
Creative creative1 =
new Creative("Standard Mars Trip", "Fly coach to Mars", "Free in-flight pretzels");
creatives.add(creative1);
Creative creative2 = new Creative("Deluxe Mars Trip", "Fly first class to Mars",
"Unlimited powdered orange drink");
creatives.add(creative2);
marsTourPromotion.setCreatives(creatives.toArray(new Creative[creatives.size()]));
Promotion[] addedPromotions = promotionService.mutate(
new PromotionOperation[] {new PromotionOperation(Operator.ADD, null, marsTourPromotion)});
System.out.printf("Added promotion ID %d with name '%s' to business ID %d%n",
addedPromotions[0].getId(), addedPromotions[0].getName(), businessId);