/// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="adGroupId">Id of the ad group to which ads are added.
    /// </param>
    public void Run(AdWordsUser user, long campaignId) {
      // Get the AdGroupAdService.
      AdGroupBidModifierService adGroupBidModifierService =
          (AdGroupBidModifierService) user.GetService(
              AdWordsService.v201506.AdGroupBidModifierService);

      // Get all ad group bid modifiers for the campaign.
      Selector selector = new Selector() {
        fields = new String[] {
          AdGroupBidModifier.Fields.CampaignId, AdGroupBidModifier.Fields.AdGroupId,
          AdGroupBidModifier.Fields.BidModifier, AdGroupBidModifier.Fields.BidModifierSource,
          Criterion.Fields.CriteriaType, Criterion.Fields.Id
        },
        predicates = new Predicate[] {
          Predicate.Equals(AdGroupBidModifier.Fields.CampaignId, campaignId)
        },
        paging = Paging.Default
      };

      AdGroupBidModifierPage page = new AdGroupBidModifierPage();

      try {
        do {
          // Get the campaigns.
          page = adGroupBidModifierService.get(selector);

          // Display the results.
          if (page != null && page.entries != null) {
            int i = selector.paging.startIndex;
            foreach (AdGroupBidModifier adGroupBidModifier in page.entries) {
              string bidModifier = (adGroupBidModifier.bidModifierSpecified) ?
                  adGroupBidModifier.bidModifier.ToString() : "UNSET";
              Console.WriteLine("{0}) Campaign ID {1}, AdGroup ID {2}, Criterion ID {3} has " +
                  "ad group level modifier: {4} and source = {5}.",
                  i + 1, adGroupBidModifier.campaignId,
                  adGroupBidModifier.adGroupId, adGroupBidModifier.criterion.id, bidModifier,
                  adGroupBidModifier.bidModifierSource);
              i++;
            }
          }
          selector.paging.IncreaseOffset();
        } while (selector.paging.startIndex < page.totalNumEntries);
        Console.WriteLine("Number of adgroup bid modifiers found: {0}", page.totalNumEntries);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to retrieve adgroup bid modifiers.", e);
      }
    }
    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="adGroupId">Id of the ad group to which ads are added.
    /// </param>
    public void Run(AdWordsUser user, long campaignId) {
      // Get the AdGroupAdService.
      AdGroupBidModifierService adGroupBidModifierService =
          (AdGroupBidModifierService) user.GetService(
              AdWordsService.v201506.AdGroupBidModifierService);

      const int PAGE_SIZE = 500;

      // Get all ad group bid modifiers for the campaign.
      Selector selector = new Selector();
      selector.fields = new String[] {"CampaignId", "AdGroupId", "BidModifier", "BidModifierSource",
        "CriteriaType", "Id"};

      Predicate predicate = new Predicate();
      predicate.field = "CampaignId";
      predicate.@operator = PredicateOperator.EQUALS;
      predicate.values = new string[] {campaignId.ToString()};
      selector.predicates = new Predicate[] {predicate};

      // Set the selector paging.
      selector.paging = new Paging();

      int offset = 0;
      int pageSize = PAGE_SIZE;

      AdGroupBidModifierPage page = new AdGroupBidModifierPage();

      try {
        do {
          selector.paging.startIndex = offset;
          selector.paging.numberResults = pageSize;

          // Get the campaigns.
          page = adGroupBidModifierService.get(selector);

          // Display the results.
          if (page != null && page.entries != null) {
            int i = offset;
            foreach (AdGroupBidModifier adGroupBidModifier in page.entries) {
              string bidModifier = (adGroupBidModifier.bidModifierSpecified)?
                  adGroupBidModifier.bidModifier.ToString() : "UNSET";
              Console.WriteLine("{0}) Campaign ID {1}, AdGroup ID {2}, Criterion ID {3} has " +
                  "ad group level modifier: {4} and source = {5}.",
                  i + 1, adGroupBidModifier.campaignId,
                  adGroupBidModifier.adGroupId, adGroupBidModifier.criterion.id, bidModifier,
                  adGroupBidModifier.bidModifierSource);
              i++;
            }
          }
          offset += pageSize;
        } while (offset < page.totalNumEntries);
        Console.WriteLine("Number of adgroup bid modifiers found: {0}", page.totalNumEntries);
      } catch (Exception ex) {
        throw new System.ApplicationException("Failed to retrieve adgroup bid modifiers.", ex);
      }
    }