Search in sources :

Example 1 with BiddingStrategyReturnValue

use of com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyReturnValue 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;
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) BiddingStrategyOperation(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyOperation) TargetSpendBiddingScheme(com.google.api.ads.adwords.axis.v201809.cm.TargetSpendBiddingScheme) BiddingStrategyServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyServiceInterface) SharedBiddingStrategy(com.google.api.ads.adwords.axis.v201809.cm.SharedBiddingStrategy) BiddingStrategyReturnValue(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyReturnValue)

Aggregations

BiddingStrategyOperation (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyOperation)1 BiddingStrategyReturnValue (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyReturnValue)1 BiddingStrategyServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyServiceInterface)1 Money (com.google.api.ads.adwords.axis.v201809.cm.Money)1 SharedBiddingStrategy (com.google.api.ads.adwords.axis.v201809.cm.SharedBiddingStrategy)1 TargetSpendBiddingScheme (com.google.api.ads.adwords.axis.v201809.cm.TargetSpendBiddingScheme)1