}
public static void runExample(AdWordsUser user, Long adGroupId)
throws Exception {
// Get the AdGroupBidModifierService.
AdGroupBidModifierServiceInterface bidModifierService =
user.getService(AdWordsService.V201306.ADGROUP_BID_MODIFIER_SERVICE);
// Create mobile platform. The ID can be found in the documentation.
// https://developers.google.com/adwords/api/docs/appendix/platforms
Platform mobile = new Platform();
mobile.setId(30001L);
AdGroupBidModifier adGroupBidModifier = new AdGroupBidModifier();
adGroupBidModifier.setAdGroupId(adGroupId);
adGroupBidModifier.setBidModifier(BID_MODIFIER);
adGroupBidModifier.setCriterion(mobile);
// Create ADD operation.
AdGroupBidModifierOperation operation = new AdGroupBidModifierOperation();
operation.setOperand(adGroupBidModifier);
// Use 'ADD' to add a new modifier and 'SET' to update an existing one. A
// modifier can be removed with the 'REMOVE' operator.
operation.setOperator(Operator.ADD);
// Update ad group bid modifier.
AdGroupBidModifierReturnValue result =
bidModifierService.mutate(new AdGroupBidModifierOperation[] {operation});
for (AdGroupBidModifier bidModifierResult : result.getValue()) {
System.out.printf(
"Campaign ID '%d', AdGroup ID '%d' was updated with ad group level modifier: %.2f\n",
bidModifierResult.getCampaignId(), bidModifierResult.getAdGroupId(),
bidModifierResult.getBidModifier());