/// <summary>
    /// Creates a FeedItemOperation that will create a FeedItem with the
    /// specified values and ad group target when sent to
    /// FeedItemService.mutate.
    /// </summary>
    /// <param name="adCustomizerFeed">The ad customizer feed.</param>
    /// <param name="name">The value for the name attribute of the FeedItem.
    /// </param>
    /// <param name="price">The value for the price attribute of the FeedItem.
    /// </param>
    /// <param name="date">The value for the date attribute of the FeedItem.
    /// </param>
    /// <param name="adGroupId">The ID of the ad group to target with the
    /// FeedItem.</param>
    /// <returns>A new FeedItemOperation for adding a FeedItem.</returns>
    private static FeedItemOperation CreateFeedItemAddOperation(AdCustomizerFeed adCustomizerFeed,
        string name, string price, String date, long adGroupId) {
      FeedItem feedItem = new FeedItem();
      feedItem.feedId = adCustomizerFeed.feedId;
      List<FeedItemAttributeValue> attributeValues = new List<FeedItemAttributeValue>();

      // FeedAttributes appear in the same order as they were created
      // - Name, Price, Date. See CreateCustomizerFeed method for details.
      FeedItemAttributeValue nameAttributeValue = new FeedItemAttributeValue();
      nameAttributeValue.feedAttributeId = adCustomizerFeed.feedAttributes[0].id;
      nameAttributeValue.stringValue = name;
      attributeValues.Add(nameAttributeValue);

      FeedItemAttributeValue priceAttributeValue = new FeedItemAttributeValue();
      priceAttributeValue.feedAttributeId = adCustomizerFeed.feedAttributes[1].id;
      priceAttributeValue.stringValue = price;
      attributeValues.Add(priceAttributeValue);

      FeedItemAttributeValue dateAttributeValue = new FeedItemAttributeValue();
      dateAttributeValue.feedAttributeId = adCustomizerFeed.feedAttributes[2].id;
      dateAttributeValue.stringValue = date;
      attributeValues.Add(dateAttributeValue);

      feedItem.attributeValues = attributeValues.ToArray();

      feedItem.adGroupTargeting = new FeedItemAdGroupTargeting();
      feedItem.adGroupTargeting.TargetingAdGroupId = adGroupId;

      FeedItemOperation feedItemOperation = new FeedItemOperation();
      feedItemOperation.operand = feedItem;
      feedItemOperation.@operator = Operator.ADD;

      return feedItemOperation;
    }
    /// <summary>
    /// Creates a new Feed for ad customizers.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="feedName">Name of the feed to be created.</param>
    /// <returns>A new Ad customizer feed.</returns>
    private static AdCustomizerFeed CreateCustomizerFeed(AdWordsUser user, string feedName) {
      AdCustomizerFeedService adCustomizerFeedService = (AdCustomizerFeedService) user.GetService(
          AdWordsService.v201506.AdCustomizerFeedService);

      AdCustomizerFeed feed = new AdCustomizerFeed() {
        feedName = feedName,
        feedAttributes = new AdCustomizerFeedAttribute[] {
          new AdCustomizerFeedAttribute() {
            name = "Name",
            type = AdCustomizerFeedAttributeType.STRING
          },
          new AdCustomizerFeedAttribute() {
            name = "Price",
            type = AdCustomizerFeedAttributeType.PRICE
          },
          new AdCustomizerFeedAttribute() {
            name = "Date",
            type = AdCustomizerFeedAttributeType.DATE_TIME
          },
        }
      };

      AdCustomizerFeedOperation feedOperation = new AdCustomizerFeedOperation();
      feedOperation.operand = feed;
      feedOperation.@operator = (Operator.ADD);

      AdCustomizerFeed addedFeed = adCustomizerFeedService.mutate(
          new AdCustomizerFeedOperation[] { feedOperation }).value[0];

      Console.WriteLine("Created ad customizer feed with ID = {0} and name = '{1}'.",
          addedFeed.feedId, addedFeed.feedName);

      return addedFeed;
    }
    /// <summary>
    /// Creates FeedItems with the values to use in ad customizations for each
    /// ad group in <code>adGroupIds</code>.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="adGroupIds">IDs of adgroups to which ad customizations are
    /// made.</param>
    /// <param name="adCustomizerFeed">The ad customizer feed.</param>
    private static void CreateCustomizerFeedItems(AdWordsUser user, long[] adGroupIds,
        AdCustomizerFeed adCustomizerFeed) {
      // Get the FeedItemService.
      FeedItemService feedItemService = (FeedItemService) user.GetService(
          AdWordsService.v201506.FeedItemService);

      List<FeedItemOperation> feedItemOperations = new List<FeedItemOperation>();

      DateTime marsDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
      feedItemOperations.Add(CreateFeedItemAddOperation(adCustomizerFeed, "Mars", "$1234.56",
          marsDate.ToString("yyyyMMdd HHmmss"), adGroupIds[0]));

      DateTime venusDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 15);
      feedItemOperations.Add(CreateFeedItemAddOperation(adCustomizerFeed, "Venus", "$1450.00",
          venusDate.ToString("yyyyMMdd HHmmss"), adGroupIds[1]));

      FeedItemReturnValue feedItemReturnValue = feedItemService.mutate(
          feedItemOperations.ToArray());

      foreach (FeedItem addedFeedItem in feedItemReturnValue.value) {
        Console.WriteLine("Added feed item with ID {0}", addedFeedItem.feedItemId);
      }
    }