Search in sources :

Example 16 with BudgetOperation

use of com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation in project googleads-java-lib by googleads.

the class UsePortfolioBiddingStrategy method createSharedBudget.

/**
 * Creates an explicit budget to be used only to create the Campaign.
 *
 * @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 Budget createSharedBudget(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    // Get the BudgetService, which loads the required classes.
    BudgetServiceInterface budgetService = adWordsServices.get(session, BudgetServiceInterface.class);
    // Create a shared budget.
    Budget budget = new Budget();
    budget.setName("Shared Interplanetary Budget #" + System.currentTimeMillis());
    budget.setAmount(new Money(null, 50000000L));
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    budget.setIsExplicitlyShared(true);
    BudgetOperation operation = new BudgetOperation();
    operation.setOperand(budget);
    operation.setOperator(Operator.ADD);
    BudgetOperation[] operations = new BudgetOperation[] { operation };
    // Make the mutate request.
    BudgetReturnValue result = budgetService.mutate(operations);
    Budget newBudget = result.getValue(0);
    System.out.printf("Budget with name '%s', ID %d was created.%n", newBudget.getName(), newBudget.getBudgetId());
    return newBudget;
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) BudgetOperation(com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation) BudgetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.BudgetServiceInterface) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget) BudgetReturnValue(com.google.api.ads.adwords.axis.v201809.cm.BudgetReturnValue)

Aggregations

Budget (com.google.api.ads.adwords.axis.v201809.cm.Budget)11 BudgetOperation (com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation)11 Money (com.google.api.ads.adwords.axis.v201809.cm.Money)10 BudgetServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.BudgetServiceInterface)8 Budget (com.google.api.ads.adwords.jaxws.v201809.cm.Budget)4 BudgetOperation (com.google.api.ads.adwords.jaxws.v201809.cm.BudgetOperation)4 Money (com.google.api.ads.adwords.jaxws.v201809.cm.Money)4 AdWordsSession (com.google.api.ads.adwords.lib.client.AdWordsSession)4 MockHttpIntegrationTest (com.google.api.ads.common.lib.testing.MockHttpIntegrationTest)4 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)4 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)4 CampaignOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation)3 AdWordsServices (com.google.api.ads.adwords.jaxws.factory.AdWordsServices)3 BudgetServiceInterface (com.google.api.ads.adwords.jaxws.v201809.cm.BudgetServiceInterface)3 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)3 Test (org.junit.Test)3 Diff (org.xmlunit.diff.Diff)3 AdWordsServices (com.google.api.ads.adwords.axis.factory.AdWordsServices)2 BiddingStrategyConfiguration (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration)2 Campaign (com.google.api.ads.adwords.axis.v201809.cm.Campaign)2