Search in sources :

Example 6 with CampaignCriterionServiceInterface

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

the class SetBidModifier method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @param campaignId the ID of the campaign.
 * @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 campaignId) throws RemoteException {
    // Get the CampaignCriterionService.
    CampaignCriterionServiceInterface campaignCriterionService = adWordsServices.get(session, CampaignCriterionServiceInterface.class);
    // Create mobile platform. The ID can be found in the documentation.
    // https://developers.google.com/adwords/api/docs/appendix/platforms
    Platform mobile = new Platform();
    mobile.setId(30001L);
    // Create criterion with modified bid.
    CampaignCriterion campaignCriterion = new CampaignCriterion();
    campaignCriterion.setCampaignId(campaignId);
    campaignCriterion.setCriterion(mobile);
    campaignCriterion.setBidModifier(BID_MODIFIER);
    // Create SET operation.
    CampaignCriterionOperation operation = new CampaignCriterionOperation();
    operation.setOperand(campaignCriterion);
    operation.setOperator(Operator.SET);
    // Update campaign criterion.
    CampaignCriterionReturnValue result = campaignCriterionService.mutate(new CampaignCriterionOperation[] { operation });
    for (CampaignCriterion campaignCriterionResult : result.getValue()) {
        System.out.printf("Campaign criterion with campaign ID %d, criterion ID %d, " + "and type '%s' was modified with bid %.4f.%n", campaignCriterionResult.getCampaignId(), campaignCriterionResult.getCriterion().getId(), campaignCriterionResult.getCriterion().getType(), campaignCriterionResult.getBidModifier());
    }
}
Also used : CampaignCriterionReturnValue(com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionReturnValue) CampaignCriterionOperation(com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionOperation) Platform(com.google.api.ads.adwords.axis.v201809.cm.Platform) CampaignCriterion(com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterion) CampaignCriterionServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionServiceInterface)

Aggregations

CampaignCriterion (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterion)6 CampaignCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionServiceInterface)6 CampaignCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionOperation)5 CampaignCriterionReturnValue (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionReturnValue)4 Language (com.google.api.ads.adwords.axis.v201809.cm.Language)3 Criterion (com.google.api.ads.adwords.axis.v201809.cm.Criterion)2 Location (com.google.api.ads.adwords.axis.v201809.cm.Location)2 ArrayList (java.util.ArrayList)2 SelectorBuilder (com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder)1 CampaignCriterionPage (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionPage)1 ConstantOperand (com.google.api.ads.adwords.axis.v201809.cm.ConstantOperand)1 Draft (com.google.api.ads.adwords.axis.v201809.cm.Draft)1 DraftOperation (com.google.api.ads.adwords.axis.v201809.cm.DraftOperation)1 DraftServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.DraftServiceInterface)1 Function (com.google.api.ads.adwords.axis.v201809.cm.Function)1 Keyword (com.google.api.ads.adwords.axis.v201809.cm.Keyword)1 LocationExtensionOperand (com.google.api.ads.adwords.axis.v201809.cm.LocationExtensionOperand)1 LocationGroups (com.google.api.ads.adwords.axis.v201809.cm.LocationGroups)1 NegativeCampaignCriterion (com.google.api.ads.adwords.axis.v201809.cm.NegativeCampaignCriterion)1 Platform (com.google.api.ads.adwords.axis.v201809.cm.Platform)1