Search in sources :

Example 1 with Budget

use of com.google.api.ads.adwords.jaxws.v201809.cm.Budget 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;
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) BudgetOperation(com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget)

Example 2 with Budget

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

the class AddCompleteCampaignsUsingBatchJob method buildCampaignOperations.

private static List<CampaignOperation> buildCampaignOperations(Iterator<Long> tempIdGenerator, String namePrefix, BudgetOperation budgetOperation) {
    long budgetId = budgetOperation.getOperand().getBudgetId();
    List<CampaignOperation> operations = new ArrayList<>();
    for (int i = 0; i < NUMBER_OF_CAMPAIGNS_TO_ADD; i++) {
        Campaign campaign = new Campaign();
        campaign.setName(String.format("Batch Campaign %s.%s", namePrefix, i));
        // Recommendation: Set the campaign to PAUSED when creating it to prevent
        // the ads from immediately serving. Set to ENABLED once you've added
        // targeting and the ads are ready to serve.
        campaign.setStatus(CampaignStatus.PAUSED);
        campaign.setId(tempIdGenerator.next());
        campaign.setAdvertisingChannelType(AdvertisingChannelType.SEARCH);
        Budget budget = new Budget();
        budget.setBudgetId(budgetId);
        campaign.setBudget(budget);
        BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        biddingStrategyConfiguration.setBiddingStrategyType(BiddingStrategyType.MANUAL_CPC);
        // You can optionally provide a bidding scheme in place of the type.
        ManualCpcBiddingScheme cpcBiddingScheme = new ManualCpcBiddingScheme();
        biddingStrategyConfiguration.setBiddingScheme(cpcBiddingScheme);
        campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
        CampaignOperation operation = new CampaignOperation();
        operation.setOperand(campaign);
        operation.setOperator(Operator.ADD);
        operations.add(operation);
    }
    return operations;
}
Also used : Campaign(com.google.api.ads.adwords.axis.v201809.cm.Campaign) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) CampaignOperation(com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation) ArrayList(java.util.ArrayList) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget) ManualCpcBiddingScheme(com.google.api.ads.adwords.axis.v201809.cm.ManualCpcBiddingScheme)

Example 3 with Budget

use of com.google.api.ads.adwords.jaxws.v201809.cm.Budget 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);
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) TrialServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.TrialServiceInterface) Trial(com.google.api.ads.adwords.axis.v201809.cm.Trial) 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) TrialOperation(com.google.api.ads.adwords.axis.v201809.cm.TrialOperation)

Example 4 with Budget

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

the class AddDynamicSearchAdsCampaign method createCampaign.

/**
 * Creates the campaign.
 */
private static Campaign createCampaign(AdWordsServicesInterface adWordsServices, AdWordsSession session, Budget budget) throws RemoteException, ApiException {
    // Get the CampaignService.
    CampaignServiceInterface campaignService = adWordsServices.get(session, CampaignServiceInterface.class);
    // Create campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
    campaign.setAdvertisingChannelType(AdvertisingChannelType.SEARCH);
    // Recommendation: Set the campaign to PAUSED when creating it to prevent
    // the ads from immediately serving. Set to ENABLED once you've added
    // targeting and the ads are ready to serve.
    campaign.setStatus(CampaignStatus.PAUSED);
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    biddingStrategyConfiguration.setBiddingStrategyType(BiddingStrategyType.MANUAL_CPC);
    campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
    // Only the budgetId should be sent, all other fields will be ignored by CampaignService.
    Budget campaignBudget = new Budget();
    campaignBudget.setBudgetId(budget.getBudgetId());
    campaign.setBudget(campaignBudget);
    // Required: Set the campaign's Dynamic Search Ads settings.
    DynamicSearchAdsSetting dynamicSearchAdsSetting = new DynamicSearchAdsSetting();
    // Required: Set the domain name and language.
    dynamicSearchAdsSetting.setDomainName("example.com");
    dynamicSearchAdsSetting.setLanguageCode("en");
    // Set the campaign settings.
    campaign.setSettings(new Setting[] { dynamicSearchAdsSetting });
    // Optional: Set the start date.
    campaign.setStartDate(DateTime.now().plusDays(1).toString("yyyyMMdd"));
    // Optional: Set the end date.
    campaign.setEndDate(DateTime.now().plusYears(1).toString("yyyyMMdd"));
    // Create the operation.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
    // Add the campaign.
    Campaign newCampaign = campaignService.mutate(new CampaignOperation[] { operation }).getValue(0);
    // Display the results.
    System.out.printf("Campaign with name '%s' and ID %d was added.%n", newCampaign.getName(), newCampaign.getId());
    return newCampaign;
}
Also used : CampaignServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface) Campaign(com.google.api.ads.adwords.axis.v201809.cm.Campaign) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) CampaignOperation(com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget) DynamicSearchAdsSetting(com.google.api.ads.adwords.axis.v201809.cm.DynamicSearchAdsSetting)

Example 5 with Budget

use of com.google.api.ads.adwords.jaxws.v201809.cm.Budget 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;
}
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)

Aggregations

Budget (com.google.api.ads.adwords.axis.v201809.cm.Budget)21 Campaign (com.google.api.ads.adwords.axis.v201809.cm.Campaign)11 Money (com.google.api.ads.adwords.axis.v201809.cm.Money)11 BudgetOperation (com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation)10 BiddingStrategyConfiguration (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration)9 CampaignOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation)9 BudgetServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.BudgetServiceInterface)8 CampaignServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface)7 CampaignReturnValue (com.google.api.ads.adwords.axis.v201809.cm.CampaignReturnValue)6 Budget (com.google.api.ads.adwords.jaxws.v201809.cm.Budget)5 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 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)4 Test (org.junit.Test)4 Diff (org.xmlunit.diff.Diff)4 AdGroup (com.google.api.ads.adwords.axis.v201809.cm.AdGroup)3