Package com.google.api.ads.adwords.axis.v201309.cm

Examples of com.google.api.ads.adwords.axis.v201309.cm.AdGroup


  }

  private static FeedItemOperation newSiteLinkFeedItemAddOperation(
      SiteLinksDataHolder siteLinksData, String text, String url, String line1, String line2) {
    // Create the FeedItemAttributeValues for our text values.
    FeedItemAttributeValue linkTextAttributeValue = new FeedItemAttributeValue();
    linkTextAttributeValue.setFeedAttributeId(siteLinksData.linkTextFeedAttributeId);
    linkTextAttributeValue.setStringValue(text);
    FeedItemAttributeValue linkUrlAttributeValue = new FeedItemAttributeValue();
    linkUrlAttributeValue.setFeedAttributeId(siteLinksData.linkUrlFeedAttributeId);
    linkUrlAttributeValue.setStringValue(url);
    FeedItemAttributeValue line1TextAttributeValue = new FeedItemAttributeValue();
    line1TextAttributeValue.setFeedAttributeId(siteLinksData.line1FeedAttributeId);
    line1TextAttributeValue.setStringValue(line1);
    FeedItemAttributeValue line2TextAttributeValue = new FeedItemAttributeValue();
    line2TextAttributeValue.setFeedAttributeId(siteLinksData.line2FeedAttributeId);
    line2TextAttributeValue.setStringValue(line2);

    // Create the feed item and operation.
    FeedItem item = new FeedItem();
    item.setFeedId(siteLinksData.siteLinksFeedId);
    item.setAttributeValues(new FeedItemAttributeValue[] {linkTextAttributeValue,
View Full Code Here


      line2AttributeValue.setStringValue(feedItemDescriptions.get(feedItem.getFeedItemId())[1]);

      itemAttributeValues[1] = line2AttributeValue;
      feedItem.setAttributeValues(itemAttributeValues);

      FeedItemOperation operation = new FeedItemOperation();
      operation.setOperator(Operator.SET);
      operation.setOperand(feedItem);
      itemOperations.add(operation);
    }
    FeedItemReturnValue itemsUpdateReturnValue =
        feedItemService.mutate(itemOperations.toArray(new FeedItemOperation[0]));
    System.out.printf("Updated %d items%n", itemsUpdateReturnValue.getValue().length);
View Full Code Here

    // Get the FeedItemService.
    FeedItemServiceInterface feedItemService =
        adWordsServices.get(session, FeedItemServiceInterface.class);

    // Create operations to add FeedItems.
    FeedItemOperation home = newSiteLinkFeedItemAddOperation(siteLinksData, "Home",
        "http://www.example.com", "Home line 1", "Home line 2");
    FeedItemOperation stores = newSiteLinkFeedItemAddOperation(siteLinksData, "Stores",
        "http://www.example.com/stores", "Stores line 1", "Stores line 2");
    FeedItemOperation onSale = newSiteLinkFeedItemAddOperation(siteLinksData, "On Sale",
        "http://www.example.com/sale", "On Sale line 1", "On Sale line 2");
    FeedItemOperation support = newSiteLinkFeedItemAddOperation(siteLinksData, "Support",
        "http://www.example.com/support", "Support line 1", "Support line 2");
    FeedItemOperation products = newSiteLinkFeedItemAddOperation(siteLinksData, "Products",
        "http://www.example.com/prods", "Products line 1", "Products line 2");
    FeedItemOperation aboutUs = newSiteLinkFeedItemAddOperation(siteLinksData, "About Us",
        "http://www.example.com/about", "About Us line 1", "About Us line 2");

    FeedItemOperation[] operations =
        new FeedItemOperation[] {home, stores, onSale, support, products, aboutUs};
View Full Code Here

    //   item.setStartTime(new DateTime(customerTimeZone).toString("yyyyMMdd HHmmss"));
    //   item.setEndTime(new DateTime(customerTimeZone).plusMonths(1).toString("yyyyMMdd HHmmss"));

    // Optional: use item.setScheduling() to specify time and days of the week for feed to deliver.
    //           This is a Beta feature.
    FeedItemOperation operation = new FeedItemOperation();
    operation.setOperand(item);
    operation.setOperator(Operator.ADD);
    return operation;
  }
View Full Code Here

      FeedItemOperation operation = new FeedItemOperation();
      operation.setOperator(Operator.SET);
      operation.setOperand(feedItem);
      itemOperations.add(operation);
    }
    FeedItemReturnValue itemsUpdateReturnValue =
        feedItemService.mutate(itemOperations.toArray(new FeedItemOperation[0]));
    System.out.printf("Updated %d items%n", itemsUpdateReturnValue.getValue().length);
  }
View Full Code Here

        "http://www.example.com/about", "About Us line 1", "About Us line 2");

    FeedItemOperation[] operations =
        new FeedItemOperation[] {home, stores, onSale, support, products, aboutUs};

    FeedItemReturnValue result = feedItemService.mutate(operations);
    for (FeedItem item : result.getValue()) {
      System.out.printf("FeedItem with feedItemId %d was added.\n", item.getFeedItemId());
      siteLinksData.siteLinkFeedItemIds.add(item.getFeedItemId());
    }
  }
View Full Code Here

   * @throws Exception
   */
  private static void updateFeedItems(AdWordsServices adWordsServices, AdWordsSession session,
      Long feedId, FeedAttribute line1Attribute, FeedAttribute line2Attribute,
      Map<Long, String[]> feedItemDescriptions) throws Exception {
    FeedItemServiceInterface feedItemService =
        adWordsServices.get(session, FeedItemServiceInterface.class);
    Selector itemSelector = new Selector();
    itemSelector.setFields(new String[] {"FeedId", "FeedItemId", "AttributeValues"});

    List<String> feedItemIds = Lists.newArrayList(
        Iterables.transform(feedItemDescriptions.keySet(), Functions.toStringFunction()));
    itemSelector.setPredicates(new Predicate[] {
        // Limit FeedItems to the feed.
        new Predicate("FeedId", PredicateOperator.EQUALS, new String[] {feedId.toString()}),
        // Limit FeedItems to the items in the feedItemDescriptions map.
        new Predicate("FeedItemId", PredicateOperator.IN, feedItemIds.toArray(new String[0]))});


    FeedItem[] feedItems = feedItemService.get(itemSelector).getEntries();

    List<FeedItemOperation> itemOperations = Lists.newArrayListWithCapacity(feedItems.length);
    for (FeedItem feedItem : feedItems) {
      // Construct a FeedItemOperation that will set the line 1 and line 2
      // attribute values for this FeedItem.
      FeedItemAttributeValue[] itemAttributeValues = new FeedItemAttributeValue[2];

      FeedItemAttributeValue line1AttributeValue = new FeedItemAttributeValue();
      line1AttributeValue.setFeedAttributeId(line1Attribute.getId());
      line1AttributeValue.setStringValue(feedItemDescriptions.get(feedItem.getFeedItemId())[0]);
      itemAttributeValues[0] = line1AttributeValue;

      FeedItemAttributeValue line2AttributeValue = new FeedItemAttributeValue();
      line2AttributeValue.setFeedAttributeId(line2Attribute.getId());
      line2AttributeValue.setStringValue(feedItemDescriptions.get(feedItem.getFeedItemId())[1]);

      itemAttributeValues[1] = line2AttributeValue;
      feedItem.setAttributeValues(itemAttributeValues);

      FeedItemOperation operation = new FeedItemOperation();
      operation.setOperator(Operator.SET);
      operation.setOperand(feedItem);
      itemOperations.add(operation);
    }
    FeedItemReturnValue itemsUpdateReturnValue =
        feedItemService.mutate(itemOperations.toArray(new FeedItemOperation[0]));
    System.out.printf("Updated %d items%n", itemsUpdateReturnValue.getValue().length);
  }
View Full Code Here

  }

  private static void createSiteLinksFeedItems(AdWordsServices adWordsServices,
      AdWordsSession session, SiteLinksDataHolder siteLinksData) throws Exception {
    // Get the FeedItemService.
    FeedItemServiceInterface feedItemService =
        adWordsServices.get(session, FeedItemServiceInterface.class);

    // Create operations to add FeedItems.
    FeedItemOperation home = newSiteLinkFeedItemAddOperation(siteLinksData, "Home",
        "http://www.example.com", "Home line 1", "Home line 2");
    FeedItemOperation stores = newSiteLinkFeedItemAddOperation(siteLinksData, "Stores",
        "http://www.example.com/stores", "Stores line 1", "Stores line 2");
    FeedItemOperation onSale = newSiteLinkFeedItemAddOperation(siteLinksData, "On Sale",
        "http://www.example.com/sale", "On Sale line 1", "On Sale line 2");
    FeedItemOperation support = newSiteLinkFeedItemAddOperation(siteLinksData, "Support",
        "http://www.example.com/support", "Support line 1", "Support line 2");
    FeedItemOperation products = newSiteLinkFeedItemAddOperation(siteLinksData, "Products",
        "http://www.example.com/prods", "Products line 1", "Products line 2");
    FeedItemOperation aboutUs = newSiteLinkFeedItemAddOperation(siteLinksData, "About Us",
        "http://www.example.com/about", "About Us line 1", "About Us line 2");

    FeedItemOperation[] operations =
        new FeedItemOperation[] {home, stores, onSale, support, products, aboutUs};

    FeedItemReturnValue result = feedItemService.mutate(operations);
    for (FeedItem item : result.getValue()) {
      System.out.printf("FeedItem with feedItemId %d was added.\n", item.getFeedItemId());
      siteLinksData.siteLinkFeedItemIds.add(item.getFeedItemId());
    }
  }
View Full Code Here

    selector.setFields(
        new String[] {"FeedId", "FeedMappingId", "PlaceholderType", "AttributeFieldMappings"});
    selector.setPredicates(new Predicate[] {
        new Predicate("FeedId", PredicateOperator.EQUALS, new String[] {feedId.toString()})});

    FeedMapping feedMapping = mappingService.get(selector).getEntries()[0];

    // Remove the existing mapping (FeedMapping is immutable).
    feedMapping = mappingService.mutate(new FeedMappingOperation[] {
        new FeedMappingOperation(Operator.REMOVE, null, feedMapping)}).getValue(0);

    // Create line 1 and line 2 attribute field mappings.
    AttributeFieldMapping line1FieldMapping = new AttributeFieldMapping();
    line1FieldMapping.setFeedAttributeId(line1FeedAttribute.getId());
    line1FieldMapping.setFieldId(PLACEHOLDER_FIELD_LINE_1_TEXT);

    AttributeFieldMapping line2FieldMapping = new AttributeFieldMapping();
    line2FieldMapping.setFeedAttributeId(line2FeedAttribute.getId());
    line2FieldMapping.setFieldId(PLACEHOLDER_FIELD_LINE_2_TEXT);

    // Combine the existing field mappings with the new mappings.
    List<AttributeFieldMapping> allFieldMappings = new ArrayList<AttributeFieldMapping>();

    // Include existing mappings.
    allFieldMappings.addAll(Arrays.asList(feedMapping.getAttributeFieldMappings()));
    // Add the new mappings for line 1 and line 2.
    allFieldMappings.add(line1FieldMapping);
    allFieldMappings.add(line2FieldMapping);

    feedMapping.setAttributeFieldMappings(allFieldMappings.toArray(new AttributeFieldMapping[0]));

    FeedMappingReturnValue mappingReturnValue = mappingService.mutate(
        new FeedMappingOperation[] {new FeedMappingOperation(Operator.ADD, null, feedMapping)});

    FeedMapping mutatedMapping = mappingReturnValue.getValue()[0];

    System.out.printf("Updated field mappings for feedId %d and feedMappingId %d to:%n",
        mutatedMapping.getFeedId(), mutatedMapping.getFeedMappingId());
    for (AttributeFieldMapping fieldMapping : mutatedMapping.getAttributeFieldMappings()) {
      System.out.printf("  feedAttributeId %d --> fieldId %d%n", fieldMapping.getFeedAttributeId(),
          fieldMapping.getFieldId());
    }
  }
View Full Code Here

    line2FieldMapping.setFeedAttributeId(siteLinksData.line2FeedAttributeId);
    line2FieldMapping.setFieldId(PLACEHOLDER_FIELD_LINE_2_TEXT);


    // Create the FieldMapping and operation.
    FeedMapping feedMapping = new FeedMapping();
    feedMapping.setPlaceholderType(PLACEHOLDER_SITELINKS);
    feedMapping.setFeedId(siteLinksData.siteLinksFeedId);
    feedMapping.setAttributeFieldMappings(new AttributeFieldMapping[] {linkTextFieldMapping,
        linkUrlFieldMapping, line1FieldMapping, line2FieldMapping});
    FeedMappingOperation operation = new FeedMappingOperation();
    operation.setOperand(feedMapping);
    operation.setOperator(Operator.ADD);
View Full Code Here

TOP

Related Classes of com.google.api.ads.adwords.axis.v201309.cm.AdGroup

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.