Search in sources :

Example 21 with Budget

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

the class JaxWsBatchJobUploadBodyProviderTest method addCampaignOperation.

@Override
protected void addCampaignOperation(BatchJobMutateRequest request, long campaignId, String campaignName, String status, String advertisingChannelType, long budgetId, String biddingStrategyType, boolean enhancedCpcEnabled) {
    Campaign campaign = new Campaign();
    campaign.setId(campaignId);
    campaign.setName(campaignName);
    campaign.setStatus(CampaignStatus.valueOf(status));
    campaign.setAdvertisingChannelType(AdvertisingChannelType.valueOf(advertisingChannelType));
    Budget budget = new Budget();
    budget.setBudgetId(budgetId);
    campaign.setBudget(budget);
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    biddingStrategyConfiguration.setBiddingStrategyType(BiddingStrategyType.valueOf(biddingStrategyType));
    ManualCpcBiddingScheme cpcBiddingScheme = new ManualCpcBiddingScheme();
    cpcBiddingScheme.setEnhancedCpcEnabled(enhancedCpcEnabled);
    biddingStrategyConfiguration.setBiddingScheme(cpcBiddingScheme);
    campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
    request.addOperation(operation);
}
Also used : Campaign(com.google.api.ads.adwords.jaxws.v201809.cm.Campaign) BiddingStrategyConfiguration(com.google.api.ads.adwords.jaxws.v201809.cm.BiddingStrategyConfiguration) CampaignOperation(com.google.api.ads.adwords.jaxws.v201809.cm.CampaignOperation) Budget(com.google.api.ads.adwords.jaxws.v201809.cm.Budget) ManualCpcBiddingScheme(com.google.api.ads.adwords.jaxws.v201809.cm.ManualCpcBiddingScheme)

Example 22 with Budget

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

the class AdWordsJaxWsSoapTimeoutIntegrationTest method testRequestTimeoutEnforced.

/**
 * Tests that the request timeout in ads.properties is enforced.
 */
@Test
public void testRequestTimeoutEnforced() throws Exception {
    testHttpServer.setMockResponseBody(SoapResponseXmlProvider.getTestSoapResponse(API_VERSION));
    testHttpServer.setDelay(200L);
    GoogleCredential credential = new GoogleCredential.Builder().setTransport(new NetHttpTransport()).setJsonFactory(new JacksonFactory()).build();
    credential.setAccessToken("TEST_ACCESS_TOKEN");
    AdWordsSession session = new AdWordsSession.Builder().withUserAgent("TEST_APP").withOAuth2Credential(credential).withEndpoint(testHttpServer.getServerUrl()).withDeveloperToken("TEST_DEVELOPER_TOKEN").withClientCustomerId("TEST_CLIENT_CUSTOMER_ID").build();
    BudgetServiceInterface budgetService = new AdWordsServices().get(session, BudgetServiceInterface.class);
    Budget budget = new Budget();
    budget.setName("Test Budget Name");
    Money money = new Money();
    money.setMicroAmount(50000000L);
    budget.setAmount(money);
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    BudgetOperation operation = new BudgetOperation();
    operation.setOperand(budget);
    operation.setOperator(Operator.ADD);
    thrown.expect(WebServiceException.class);
    thrown.expectMessage("Read timed out");
    budgetService.mutate(Lists.newArrayList(operation));
}
Also used : Money(com.google.api.ads.adwords.jaxws.v201809.cm.Money) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) AdWordsSession(com.google.api.ads.adwords.lib.client.AdWordsSession) BudgetOperation(com.google.api.ads.adwords.jaxws.v201809.cm.BudgetOperation) BudgetServiceInterface(com.google.api.ads.adwords.jaxws.v201809.cm.BudgetServiceInterface) Budget(com.google.api.ads.adwords.jaxws.v201809.cm.Budget) GoogleCredential(com.google.api.client.googleapis.auth.oauth2.GoogleCredential) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) AdWordsServices(com.google.api.ads.adwords.jaxws.factory.AdWordsServices) Test(org.junit.Test) MockHttpIntegrationTest(com.google.api.ads.common.lib.testing.MockHttpIntegrationTest)

Example 23 with Budget

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

the class AddUniversalAppCampaign method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @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) throws RemoteException {
    // Get the CampaignService.
    CampaignServiceInterface campaignService = adWordsServices.get(session, CampaignServiceInterface.class);
    // Create the campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Interplanetary Cruise App #" + System.currentTimeMillis());
    // 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);
    // Set the advertising channel and subchannel types for universal app campaigns.
    campaign.setAdvertisingChannelType(AdvertisingChannelType.MULTI_CHANNEL);
    campaign.setAdvertisingChannelSubType(AdvertisingChannelSubType.UNIVERSAL_APP_CAMPAIGN);
    // Set the campaign's bidding strategy. universal app campaigns
    // only support TARGET_CPA bidding strategy.
    BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
    biddingConfig.setBiddingStrategyType(BiddingStrategyType.TARGET_CPA);
    // Set the target CPA to $1 / app install.
    TargetCpaBiddingScheme biddingScheme = new TargetCpaBiddingScheme();
    biddingScheme.setTargetCpa(new Money());
    biddingScheme.getTargetCpa().setMicroAmount(1000000L);
    biddingConfig.setBiddingScheme(biddingScheme);
    campaign.setBiddingStrategyConfiguration(biddingConfig);
    // Set the campaign's budget.
    campaign.setBudget(new Budget());
    campaign.getBudget().setBudgetId(createBudget(adWordsServices, session));
    // 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"));
    // Set the campaign's assets and ad text ideas. These values will be used to
    // generate ads.
    UniversalAppCampaignSetting universalAppSetting = new UniversalAppCampaignSetting();
    universalAppSetting.setAppId("com.labpixies.colordrips");
    universalAppSetting.setAppVendor(MobileApplicationVendor.VENDOR_GOOGLE_MARKET);
    universalAppSetting.setDescription1("A cool puzzle game");
    universalAppSetting.setDescription2("Remove connected blocks");
    universalAppSetting.setDescription3("3 difficulty levels");
    universalAppSetting.setDescription4("4 colorful fun skins");
    // Optional: You can set up to 20 image assets for your campaign.
    // See UploadImage.java for an example on how to upload images.
    // 
    // universalAppSetting.setImageMediaIds(new long[] { INSERT_IMAGE_MEDIA_ID_HERE });
    // Optimize this campaign for getting new users for your app.
    universalAppSetting.setUniversalAppBiddingStrategyGoalType(UniversalAppBiddingStrategyGoalType.OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME);
    // If you select the OPTIMIZE_FOR_IN_APP_CONVERSION_VOLUME goal type, then also specify
    // your in-app conversion types so AdWords can focus your campaign on people who are
    // most likely to complete the corresponding in-app actions.
    // Conversion type IDs can be retrieved using ConversionTrackerService.get.
    // 
    // campaign.selectiveOptimization = new SelectiveOptimization();
    // campaign.selectiveOptimization.conversionTypeIds =
    // new long[] { INSERT_CONVERSION_TYPE_ID_1_HERE, INSERT_CONVERSION_TYPE_ID_2_HERE };
    // Optional: Set the campaign settings for Advanced location options.
    GeoTargetTypeSetting geoSetting = new GeoTargetTypeSetting();
    geoSetting.setPositiveGeoTargetType(GeoTargetTypeSettingPositiveGeoTargetType.LOCATION_OF_PRESENCE);
    geoSetting.setNegativeGeoTargetType(GeoTargetTypeSettingNegativeGeoTargetType.DONT_CARE);
    campaign.setSettings(new Setting[] { universalAppSetting, geoSetting });
    // Create the operation.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
    CampaignOperation[] operations = new CampaignOperation[] { operation };
    // Add the campaign.
    CampaignReturnValue result = campaignService.mutate(operations);
    // Display the results.
    for (Campaign newCampaign : result.getValue()) {
        System.out.printf("Universal app campaign with name '%s' and ID %d was added.%n", newCampaign.getName(), newCampaign.getId());
        // Optional: Set the campaign's location and language targeting. No other targeting
        // criteria can be used for universal app campaigns.
        setCampaignTargetingCriteria(newCampaign, adWordsServices, session);
    }
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) CampaignServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface) Campaign(com.google.api.ads.adwords.axis.v201809.cm.Campaign) UniversalAppCampaignSetting(com.google.api.ads.adwords.axis.v201809.cm.UniversalAppCampaignSetting) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) CampaignOperation(com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation) CampaignReturnValue(com.google.api.ads.adwords.axis.v201809.cm.CampaignReturnValue) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget) TargetCpaBiddingScheme(com.google.api.ads.adwords.axis.v201809.cm.TargetCpaBiddingScheme) GeoTargetTypeSetting(com.google.api.ads.adwords.axis.v201809.cm.GeoTargetTypeSetting)

Example 24 with Budget

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

the class UsePortfolioBiddingStrategy method createCampaignWithBiddingStrategy.

/**
 * Create a Campaign with a portfolio bidding strategy.
 *
 * @param adWordsServices the user to run the example with
 * @param session the AdWordsSession
 * @param biddingStrategyId the bidding strategy id to use
 * @param sharedBudgetId the shared budget id to use
 * @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 Campaign createCampaignWithBiddingStrategy(AdWordsServicesInterface adWordsServices, AdWordsSession session, Long biddingStrategyId, Long sharedBudgetId) throws RemoteException {
    // Get the CampaignService, which loads the required classes.
    CampaignServiceInterface campaignService = adWordsServices.get(session, CampaignServiceInterface.class);
    // Create campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
    // 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);
    // Set the budget.
    Budget budget = new Budget();
    budget.setBudgetId(sharedBudgetId);
    campaign.setBudget(budget);
    // Set bidding strategy (required).
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    biddingStrategyConfiguration.setBiddingStrategyId(biddingStrategyId);
    campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
    // Set advertising channel type (required).
    campaign.setAdvertisingChannelType(AdvertisingChannelType.SEARCH);
    // Set network targeting (recommended).
    NetworkSetting networkSetting = new NetworkSetting();
    networkSetting.setTargetGoogleSearch(true);
    networkSetting.setTargetSearchNetwork(true);
    networkSetting.setTargetContentNetwork(true);
    campaign.setNetworkSetting(networkSetting);
    // Create operation.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
    CampaignReturnValue result = campaignService.mutate(new CampaignOperation[] { operation });
    Campaign newCampaign = result.getValue(0);
    System.out.printf("Campaign with name '%s', ID %d and bidding scheme ID %d was created.%n", newCampaign.getName(), newCampaign.getId(), newCampaign.getBiddingStrategyConfiguration().getBiddingStrategyId());
    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) CampaignReturnValue(com.google.api.ads.adwords.axis.v201809.cm.CampaignReturnValue) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget) NetworkSetting(com.google.api.ads.adwords.axis.v201809.cm.NetworkSetting)

Example 25 with Budget

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