use of com.google.api.ads.adwords.axis.v201809.cm.SharedBiddingStrategy in project googleads-java-lib by googleads.
the class UsePortfolioBiddingStrategy method runExample.
/**
* Runs the example.
*
* @param adWordsServices the services factory.
* @param session the session.
* @param sharedBudgetId the ID of the shared budget to use. If null, this example will create a
* new shared budget.
* @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, @Nullable Long sharedBudgetId) throws RemoteException {
SharedBiddingStrategy portfolioBiddingStrategy = createBiddingStrategy(adWordsServices, session);
if (sharedBudgetId == null) {
Budget budget = createSharedBudget(adWordsServices, session);
sharedBudgetId = budget.getBudgetId();
}
createCampaignWithBiddingStrategy(adWordsServices, session, portfolioBiddingStrategy.getId(), sharedBudgetId);
}
use of com.google.api.ads.adwords.axis.v201809.cm.SharedBiddingStrategy in project googleads-java-lib by googleads.
the class UsePortfolioBiddingStrategy method createBiddingStrategy.
/**
* Creates the bidding strategy object.
*
* @param adWordsServices the user to run the example with
* @param session the AdWordsSession
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
private static SharedBiddingStrategy createBiddingStrategy(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
// Get the BiddingStrategyService, which loads the required classes.
BiddingStrategyServiceInterface biddingStrategyService = adWordsServices.get(session, BiddingStrategyServiceInterface.class);
// Create a portfolio bidding strategy.
SharedBiddingStrategy portfolioBiddingStrategy = new SharedBiddingStrategy();
portfolioBiddingStrategy.setName("Maximize Clicks" + System.currentTimeMillis());
TargetSpendBiddingScheme biddingScheme = new TargetSpendBiddingScheme();
// Optionally set additional bidding scheme parameters.
biddingScheme.setBidCeiling(new Money(null, 2000000L));
biddingScheme.setSpendTarget(new Money(null, 20000000L));
portfolioBiddingStrategy.setBiddingScheme(biddingScheme);
// Create operation.
BiddingStrategyOperation operation = new BiddingStrategyOperation();
operation.setOperand(portfolioBiddingStrategy);
operation.setOperator(Operator.ADD);
BiddingStrategyOperation[] operations = new BiddingStrategyOperation[] { operation };
BiddingStrategyReturnValue result = biddingStrategyService.mutate(operations);
SharedBiddingStrategy newBiddingStrategy = result.getValue(0);
System.out.printf("Portfolio bidding strategy with name '%s' and ID %d of type '%s' was created.%n", newBiddingStrategy.getName(), newBiddingStrategy.getId(), newBiddingStrategy.getBiddingScheme().getBiddingSchemeType());
return newBiddingStrategy;
}
Aggregations