use of com.google.api.ads.adwords.jaxws.v201809.cm.Money in project googleads-java-lib by googleads.
the class AddCompleteCampaignsUsingBatchJob method buildBudgetOperation.
private static BudgetOperation buildBudgetOperation(Iterator<Long> tempIdGenerator, String namePrefix) {
Budget budget = new Budget();
budget.setBudgetId(tempIdGenerator.next());
budget.setName(String.format("Interplanetary Cruise %s", namePrefix));
Money budgetAmount = new Money();
budgetAmount.setMicroAmount(50000000L);
budget.setAmount(budgetAmount);
budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
BudgetOperation budgetOperation = new BudgetOperation();
budgetOperation.setOperand(budget);
budgetOperation.setOperator(Operator.ADD);
return budgetOperation;
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Money in project googleads-java-lib by googleads.
the class GraduateTrial method runExample.
/**
* Runs the example.
*
* @param adWordsServices the services factory.
* @param session the session.
* @param trialId the ID of the trial to graduate.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session, long trialId) throws RemoteException {
// Get the TrialService and BudgetService.
TrialServiceInterface trialService = adWordsServices.get(session, TrialServiceInterface.class);
BudgetServiceInterface budgetService = adWordsServices.get(session, BudgetServiceInterface.class);
// To graduate a trial, you must specify a different budget from the base campaign. The base
// campaign (in order to have had a trial based on it) must have a non-shared budget, so it
// cannot be shared with the new independent campaign created by graduation.
Budget budget = new Budget();
budget.setName("Budget #" + System.currentTimeMillis());
Money budgetAmount = new Money();
budgetAmount.setMicroAmount(50000000L);
budget.setAmount(budgetAmount);
budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
BudgetOperation budgetOperation = new BudgetOperation();
budgetOperation.setOperator(Operator.ADD);
budgetOperation.setOperand(budget);
// Add budget.
long budgetId = budgetService.mutate(new BudgetOperation[] { budgetOperation }).getValue(0).getBudgetId();
Trial trial = new Trial();
trial.setId(trialId);
trial.setBudgetId(budgetId);
trial.setStatus(TrialStatus.GRADUATED);
TrialOperation trialOperation = new TrialOperation();
trialOperation.setOperator(Operator.SET);
trialOperation.setOperand(trial);
// Update the trial.
trial = trialService.mutate(new TrialOperation[] { trialOperation }).getValue(0);
// Graduation is a synchronous operation, so the campaign is already ready. If you promote
// instead, make sure to see the polling scheme demonstrated in AddTrial.java to wait for the
// asynchronous operation to finish.
System.out.printf("Trial ID %d graduated. Campaign ID %d was given a new budget ID %d and " + "is no longer dependent on this trial.%n", trial.getId(), trial.getTrialCampaignId(), budgetId);
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Money in project googleads-java-lib by googleads.
the class AddDynamicSearchAdsCampaign method addWebPageCriteria.
/**
* Adds a web page criteria to target Dynamic Search Ads.
*/
private static void addWebPageCriteria(AdWordsServicesInterface adWordsServices, AdWordsSession session, AdGroup adGroup) throws ApiException, RemoteException {
// Get the AdGroupCriterionService.
AdGroupCriterionServiceInterface adGroupCriterionService = adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
// Create a webpage criterion for special offers.
WebpageParameter param = new WebpageParameter();
param.setCriterionName("Special offers");
WebpageCondition urlCondition = new WebpageCondition();
urlCondition.setOperand(WebpageConditionOperand.URL);
urlCondition.setArgument("/specialoffers");
WebpageCondition titleCondition = new WebpageCondition();
titleCondition.setOperand(WebpageConditionOperand.PAGE_TITLE);
titleCondition.setArgument("Special Offer");
param.setConditions(new WebpageCondition[] { urlCondition, titleCondition });
Webpage webpage = new Webpage();
webpage.setParameter(param);
// Create biddable ad group criterion.
BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
biddableAdGroupCriterion.setAdGroupId(adGroup.getId());
biddableAdGroupCriterion.setCriterion(webpage);
biddableAdGroupCriterion.setUserStatus(UserStatus.PAUSED);
// Optional: set a custom bid.
BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
CpcBid bid = new CpcBid();
bid.setBid(new Money());
bid.getBid().setMicroAmount(10000000L);
biddingStrategyConfiguration.setBids(new Bids[] { bid });
biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
// Create operations.
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
operation.setOperator(Operator.ADD);
operation.setOperand(biddableAdGroupCriterion);
// Create the criterion.
AdGroupCriterion newAdGroupCriterion = adGroupCriterionService.mutate(new AdGroupCriterionOperation[] { operation }).getValue(0);
System.out.printf("Webpage criterion with ID %d was added to ad group ID %d.%n", newAdGroupCriterion.getCriterion().getId(), newAdGroupCriterion.getAdGroupId());
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Money in project googleads-java-lib by googleads.
the class AddDynamicSearchAdsCampaign method createAdGroup.
/**
* Creates the ad group.
*/
private static AdGroup createAdGroup(AdWordsServicesInterface adWordsServices, AdWordsSession session, Campaign campaign) throws ApiException, RemoteException {
// Get the AdGroupService.
AdGroupServiceInterface adGroupService = adWordsServices.get(session, AdGroupServiceInterface.class);
// Create the ad group.
AdGroup adGroup = new AdGroup();
// Required: Set the ad group's type to Dynamic Search Ads.
adGroup.setAdGroupType(AdGroupType.SEARCH_DYNAMIC_ADS);
adGroup.setName("Earth to Mars Cruises #" + System.currentTimeMillis());
adGroup.setCampaignId(campaign.getId());
adGroup.setStatus(AdGroupStatus.PAUSED);
// Recommended: Set a tracking URL template for your ad group if you want to use URL
// tracking software.
adGroup.setTrackingUrlTemplate("http://tracker.example.com/traveltracker/{escapedlpurl}");
// Set the ad group bids.
BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
CpcBid cpcBid = new CpcBid();
cpcBid.setBid(new Money());
cpcBid.getBid().setMicroAmount(3000000L);
biddingConfig.setBids(new Bids[] { cpcBid });
adGroup.setBiddingStrategyConfiguration(biddingConfig);
// Create the operation.
AdGroupOperation operation = new AdGroupOperation();
operation.setOperand(adGroup);
operation.setOperator(Operator.ADD);
AdGroup newAdGroup = adGroupService.mutate(new AdGroupOperation[] { operation }).getValue(0);
System.out.printf("Ad group with name '%s' and ID %d was added.%n", newAdGroup.getName(), newAdGroup.getId());
return newAdGroup;
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Money in project googleads-java-lib by googleads.
the class AddDynamicSearchAdsCampaign method createBudget.
/**
* Creates the budget.
*/
private static Budget createBudget(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException, ApiException {
// Get the BudgetService.
BudgetServiceInterface budgetService = adWordsServices.get(session, BudgetServiceInterface.class);
// Create a budget, which can be shared by multiple campaigns.
Budget sharedBudget = new Budget();
sharedBudget.setName("Interplanetary Cruise #" + System.currentTimeMillis());
Money budgetAmount = new Money();
budgetAmount.setMicroAmount(50000000L);
sharedBudget.setAmount(budgetAmount);
sharedBudget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
BudgetOperation budgetOperation = new BudgetOperation();
budgetOperation.setOperand(sharedBudget);
budgetOperation.setOperator(Operator.ADD);
// Add the budget
Budget budget = budgetService.mutate(new BudgetOperation[] { budgetOperation }).getValue(0);
return budget;
}
Aggregations