Package com.google.api.adwords.v201008.cm

Examples of com.google.api.adwords.v201008.cm.AdGroupAdOperation


      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(ad);

      // Create operations.
      AdGroupAdOperation operation = new AdGroupAdOperation();
      operation.setOperand(adGroupAd);
      operation.setOperator(Operator.REMOVE);

      AdGroupAdOperation[] operations = new AdGroupAdOperation[] {operation};

      // Delete ad.
      AdGroupAdReturnValue result = adGroupAdService.mutate(operations);
View Full Code Here


      AdGroupAd imageAdGroupAd = new AdGroupAd();
      imageAdGroupAd.setAdGroupId(adGroupId);
      imageAdGroupAd.setAd(imageAd);

      // Create operations.
      AdGroupAdOperation imageAdGroupAdOperation = new AdGroupAdOperation();
      imageAdGroupAdOperation.setOperand(imageAdGroupAd);
      imageAdGroupAdOperation.setOperator(Operator.ADD);

      AdGroupAdOperation[] operations = new AdGroupAdOperation[] {imageAdGroupAdOperation};

      // Add ads.
      AdGroupAdReturnValue result = adGroupAdService.mutate(operations);
View Full Code Here

      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(thirdPartyRedirectAd);

      // Create operations.
      AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
      adGroupAdOperation.setOperand(adGroupAd);
      adGroupAdOperation.setOperator(Operator.ADD);

      // Create In Stream ad.
      ThirdPartyRedirectAd inStreamAd = new ThirdPartyRedirectAd();
      inStreamAd.setName("Cruise to Mars #" + System.currentTimeMillis());
      inStreamAd.setUrl("http://www.example.com");
      inStreamAd.setSourceUrl("http://www.example.com");
      inStreamAd.setAdDuration(15000);
      inStreamAd.setUrl(
          "http://ad.doubleclick.net/pfadx/N270.126913.6102203221521/B3876671.21;dcadv=2215309;sz=0x0;ord=%5btimestamp%5d;dcmt=text/xml");
      inStreamAd.setCertifiedVendorFormatId(303L);
      inStreamAd.setRichMediaAdType(RichMediaAdRichMediaAdType.fromValue("IN_STREAM_VIDEO"));

      // Create ad group ad.
      AdGroupAd adGroupAd2 = new AdGroupAd();
      adGroupAd2.setAdGroupId(adGroupId);
      adGroupAd2.setAd(inStreamAd);

      // Create operations.
      AdGroupAdOperation adGroupAdOperation2 = new AdGroupAdOperation();
      adGroupAdOperation2.setOperand(adGroupAd2);
      adGroupAdOperation2.setOperator(Operator.ADD);

      AdGroupAdOperation[] operations =
          new AdGroupAdOperation[] {adGroupAdOperation, adGroupAdOperation2};

      // Add ads.
View Full Code Here

    // Optional: Set the status.
    clickToDownloadAppAdGroupAd.setStatus(AdGroupAdStatus.PAUSED);

    // Create the operation.
    AdGroupAdOperation operation = new AdGroupAdOperation();
    operation.setOperator(Operator.ADD);
    operation.setOperand(clickToDownloadAppAdGroupAd);

    // Create the ads.
    AdGroupAdReturnValue result = adGroupAdService.mutate(new AdGroupAdOperation[] {operation});

    for (AdGroupAd adGroupAd : result.getValue()) {
View Full Code Here

      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(ad);
      adGroupAd.setStatus(AdGroupAdStatus.PAUSED);

      // Create operations.
      AdGroupAdOperation operation = new AdGroupAdOperation();
      operation.setOperand(adGroupAd);
      operation.setOperator(Operator.SET);

      AdGroupAdOperation[] operations = new AdGroupAdOperation[] {operation};

      // Update ad.
      AdGroupAdReturnValue result = adGroupAdService.mutate(operations);
View Full Code Here

      AdGroupAd templateAdGroupAd = new AdGroupAd();
      templateAdGroupAd.setAdGroupId(adGroupId);
      templateAdGroupAd.setAd(templateAd);

      // Create operations.
      AdGroupAdOperation textAdGroupAdOperation = new AdGroupAdOperation();
      textAdGroupAdOperation.setOperand(textAdGroupAd);
      textAdGroupAdOperation.setOperator(Operator.ADD);

      AdGroupAdOperation imageAdGroupAdOperation = new AdGroupAdOperation();
      imageAdGroupAdOperation.setOperand(imageAdGroupAd);
      imageAdGroupAdOperation.setOperator(Operator.ADD);

      AdGroupAdOperation templateAdGroupAdOperation = new AdGroupAdOperation();
      templateAdGroupAdOperation.setOperand(templateAdGroupAd);
      templateAdGroupAdOperation.setOperator(Operator.ADD);

      AdGroupAdOperation[] operations = new AdGroupAdOperation[] {textAdGroupAdOperation,
          imageAdGroupAdOperation, templateAdGroupAdOperation};

      // Add ads.
View Full Code Here

      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(ad);

      // Create operations.
      AdGroupAdOperation operation = new AdGroupAdOperation();
      operation.setOperand(adGroupAd);
      operation.setOperator(Operator.REMOVE);

      AdGroupAdOperation[] operations = new AdGroupAdOperation[] {operation};

      // Delete ad.
      AdGroupAdReturnValue result = adGroupAdService.mutate(operations);
View Full Code Here

      AdGroupAd exemptableAdGroupAd = new AdGroupAd();
      exemptableAdGroupAd.setAdGroupId(adGroupId);
      exemptableAdGroupAd.setAd(exemptableTextAd);

      // Create operations.
      AdGroupAdOperation exemptableOperation = new AdGroupAdOperation();
      exemptableOperation.setOperand(exemptableAdGroupAd);
      exemptableOperation.setOperator(Operator.ADD);

      // Create text ad that violates an non-exemptable policy.
      TextAd nonExemptableTextAd = new TextAd();
      nonExemptableTextAd.setHeadline("Mars Cruise with too long of a headline.");
      nonExemptableTextAd.setDescription1("Visit the Red Planet in style.");
      nonExemptableTextAd.setDescription2("Low-gravity fun for everyone.");
      nonExemptableTextAd.setDisplayUrl("www.example.com");
      nonExemptableTextAd.setUrl("http://www.example.com/");

      // Create ad group ad.
      AdGroupAd nonExemptableAdGroupAd = new AdGroupAd();
      nonExemptableAdGroupAd.setAdGroupId(adGroupId);
      nonExemptableAdGroupAd.setAd(nonExemptableTextAd);

      // Create operations.
      AdGroupAdOperation nonExemptableOperation = new AdGroupAdOperation();
      nonExemptableOperation.setOperand(nonExemptableAdGroupAd);
      nonExemptableOperation.setOperator(Operator.ADD);

      AdGroupAdOperation[] operations =
          new AdGroupAdOperation[] {exemptableOperation, nonExemptableOperation};

      try {
        // Validate the ads.
        AdGroupAdReturnValue result = adGroupAdValidationService.mutate(operations);
      } catch (ApiException e) {
        Set<Integer> indicesToRemove = new HashSet<Integer>();
        for (ApiError error : e.getErrors()) {
          if (error instanceof PolicyViolationError) {
            PolicyViolationError policyVioloationError = (PolicyViolationError) error;
            Matcher matcher = operationIndexPattern.matcher(error.getFieldPath());
            if (matcher.matches()) {
              int operationIndex = Integer.parseInt(matcher.group(1));
              AdGroupAdOperation operation = operations[operationIndex];
              System.out.printf("Ad with headline \"%s\" violated %s policy \"%s\".\n",
                  ((TextAd) operation.getOperand().getAd()).getHeadline(), policyVioloationError
                      .getIsExemptable() ? "exemptable" : "non-exemptable", policyVioloationError
                      .getExternalPolicyName());
              if (policyVioloationError.getIsExemptable()) {
                // Add exemption request to the operation.
                System.out.printf(
                    "Adding exemption request for policy name \"%s\" on text \"%s\".\n",
                    policyVioloationError.getKey().getPolicyName(), policyVioloationError.getKey()
                        .getViolatingText());
                List<ExemptionRequest> exemptionRequests =
                    new ArrayList<ExemptionRequest>(Arrays
                        .asList(operation.getExemptionRequests() == null
                            ? new ExemptionRequest[] {} : operation.getExemptionRequests()));
                exemptionRequests.add(new ExemptionRequest(policyVioloationError.getKey()));
                operation
                    .setExemptionRequests(exemptionRequests.toArray(new ExemptionRequest[] {}));
              } else {
                // Remove non-exemptable operation.
                System.out.println("Removing non-exemptable operation at index " + operationIndex
                    + ".");
                indicesToRemove.add(operationIndex);
              }
            }
          } else {
            // Non-policy error returned.
            Matcher matcher = operationIndexPattern.matcher(error.getFieldPath());
            if (matcher.matches()) {
              int operationIndex = Integer.parseInt(matcher.group(1));
              AdGroupAdOperation operation = operations[operationIndex];
              System.out.printf("Ad with headline \"%s\" created non-policy error \"%s\".\n",
                  ((TextAd) operation.getOperand().getAd()).getHeadline(), error.getErrorString());
              System.out.println("Removing non-exemptable operation at index " + operationIndex
                  + ".");
              indicesToRemove.add(operationIndex);
            }
          }
View Full Code Here

      AdGroupAd imageAdGroupAd = new AdGroupAd();
      imageAdGroupAd.setAdGroupId(adGroupId);
      imageAdGroupAd.setAd(imageAd);

      // Create operations.
      AdGroupAdOperation imageAdGroupAdOperation = new AdGroupAdOperation();
      imageAdGroupAdOperation.setOperand(imageAdGroupAd);
      imageAdGroupAdOperation.setOperator(Operator.ADD);

      AdGroupAdOperation[] operations = new AdGroupAdOperation[] {imageAdGroupAdOperation};

      // Add ads.
      AdGroupAdReturnValue result = adGroupAdService.mutate(operations);
View Full Code Here

      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(thirdPartyRedirectAd);

      // Create operations.
      AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
      adGroupAdOperation.setOperand(adGroupAd);
      adGroupAdOperation.setOperator(Operator.ADD);

      // Create In Stream ad.
      ThirdPartyRedirectAd inStreamAd = new ThirdPartyRedirectAd();
      inStreamAd.setName("Cruise to Mars #" + System.currentTimeMillis());
      inStreamAd.setUrl("http://www.example.com");
      inStreamAd.setSourceUrl("http://www.example.com");
      inStreamAd.setAdDuration(15000);
      inStreamAd.setUrl(
          "http://ad.doubleclick.net/pfadx/N270.126913.6102203221521/B3876671.21;dcadv=2215309;sz=0x0;ord=%5btimestamp%5d;dcmt=text/xml");
      inStreamAd.setCertifiedVendorFormatId(303L);
      inStreamAd.setRichMediaAdType(RichMediaAdRichMediaAdType.fromValue("IN_STREAM_VIDEO"));

      // Create ad group ad.
      AdGroupAd adGroupAd2 = new AdGroupAd();
      adGroupAd2.setAdGroupId(adGroupId);
      adGroupAd2.setAd(inStreamAd);

      // Create operations.
      AdGroupAdOperation adGroupAdOperation2 = new AdGroupAdOperation();
      adGroupAdOperation2.setOperand(adGroupAd2);
      adGroupAdOperation2.setOperator(Operator.ADD);

      AdGroupAdOperation[] operations =
          new AdGroupAdOperation[] {adGroupAdOperation, adGroupAdOperation2};

      // Add ads.
View Full Code Here

TOP

Related Classes of com.google.api.adwords.v201008.cm.AdGroupAdOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.