/// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Get the VideoCampaignService.
            VideoCampaignService videoCampaignService = (VideoCampaignService)user.GetService(
                AdWordsService.v201402.VideoCampaignService);

            int offset = 0;

            VideoCampaignPage page = new VideoCampaignPage();

            try {
                // Create selector.
                VideoCampaignSelector selector = new VideoCampaignSelector();

                selector.paging = new Paging();

                do
                {
                    selector.paging.startIndex    = offset;
                    selector.paging.numberResults = PAGE_SIZE;

                    page = videoCampaignService.get(selector);

                    // Display the results.
                    if (page != null && page.entries != null)
                    {
                        int i = offset;
                        foreach (VideoCampaign videoCampaign in page.entries)
                        {
                            Console.WriteLine("{0}) Campaign ID {1}, name '{2}' and status '{3}'",
                                              (i + 1), videoCampaign.id, videoCampaign.name, videoCampaign.status);
                            i++;
                        }
                    }
                    else
                    {
                        Console.WriteLine("No campaigns were found.");
                    }
                    offset += PAGE_SIZE;
                } while (offset < page.totalNumEntries);
                Console.WriteLine("Number of campaigns found: {0}", page.totalNumEntries);
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to get campaigns.", ex);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="campaignId">The campaign ID.</param>
        public void Run(AdWordsUser user, long campaignId)
        {
            // Get the VideoCampaignService.
            VideoCampaignService videoCampaignService = (VideoCampaignService)user.GetService(
                AdWordsService.v201402.VideoCampaignService);

            // The dates will be interpreted using the account's timezone.
            String minDateTime = DateTime.Now.Year.ToString() + "0101";
            String maxDateTime = DateTime.Now.ToString("yyyyMMdd");

            // Create selector.
            StatsSelector statsSelector = new StatsSelector();
            DateRange     dateRange     = new DateRange();

            dateRange.min = minDateTime;
            dateRange.max = maxDateTime;

            statsSelector.dateRange = dateRange;
            statsSelector.segmentationDimensions = new SegmentationDimension[] {
                SegmentationDimension.DATE_MONTH
            };
            statsSelector.metrics      = new Metric[] { Metric.VIEWS, Metric.COST, Metric.AVERAGE_CPV };
            statsSelector.summaryTypes = new VideoEntityStatsSummaryType[] {
                VideoEntityStatsSummaryType.ALL
            };
            statsSelector.segmentedSummaryType = VideoEntityStatsSummaryType.ALL;

            try {
                // Create selector.
                VideoCampaignSelector selector = new VideoCampaignSelector();
                selector.statsSelector = statsSelector;
                selector.ids           = new long[] { campaignId };

                selector.paging = new Paging();

                VideoCampaignPage page = videoCampaignService.get(selector);

                if (page != null)
                {
                    if (page.entries != null && page.entries.Length > 0)
                    {
                        VideoCampaign videoCampaign = page.entries[0];

                        Console.WriteLine("Campaign ID {0}, name '{1}' and status '{2}'", videoCampaign.id,
                                          videoCampaign.name, videoCampaign.status);
                        if (videoCampaign.stats != null)
                        {
                            Console.WriteLine("\tCampaign stats:");
                            Console.WriteLine("\t\t" + FormatStats(videoCampaign.stats));
                        }
                        if (videoCampaign.segmentedStats != null)
                        {
                            foreach (VideoEntityStats segment in videoCampaign.segmentedStats)
                            {
                                Console.WriteLine("\tCampaign segmented stats for month of " +
                                                  ((DateKey)segment.segmentKey.Item).date);
                                Console.WriteLine("\t\t" + FormatStats(segment));
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("No campaigns were found.");
                    }
                    if (page.summaryStats != null)
                    {
                        foreach (VideoEntityStats summary in page.summaryStats)
                        {
                            Console.WriteLine("\tSummary of type " + summary.summaryType);
                            Console.WriteLine("\t\t" + FormatStats(summary));
                        }
                    }
                    else
                    {
                        Console.WriteLine("No summary stats found.");
                    }
                }
                else
                {
                    Console.WriteLine("No campaigns were found.");
                }
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to get campaigns.", ex);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Get the BudgetService.
            BudgetService budgetService =
                (BudgetService)user.GetService(AdWordsService.v201402.BudgetService);

            // Get the VideoCampaignService.
            VideoCampaignService videoCampaignService =
                (VideoCampaignService)user.GetService(AdWordsService.v201402.VideoCampaignService);

            // Create the campaign budget.
            Budget budget = new Budget();

            budget.name               = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString();
            budget.period             = BudgetBudgetPeriod.DAILY;
            budget.deliveryMethod     = BudgetBudgetDeliveryMethod.STANDARD;
            budget.amount             = new Money();
            budget.amount.microAmount = 500000;

            BudgetOperation budgetOperation = new BudgetOperation();

            budgetOperation.@operator = Operator.ADD;
            budgetOperation.operand   = budget;

            try {
                BudgetReturnValue budgetRetval = budgetService.mutate(new BudgetOperation[] { budgetOperation });
                budget = budgetRetval.value[0];
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to add shared budget.", ex);
            }

            // Create video campaign.
            VideoCampaign videoCampaign = new VideoCampaign();

            videoCampaign.name     = ("Interplanetary Cruise #" + ExampleUtilities.GetRandomString());
            videoCampaign.status   = VideoCampaignStatus.PAUSED;
            videoCampaign.budgetId = budget.budgetId;

            // You can optionally provide these field(s). The dates will be
            // interpreted using the account's timezone.
            videoCampaign.startDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd");

            try {
                // Create operations.
                VideoCampaignOperation operation = new VideoCampaignOperation();
                operation.operand   = videoCampaign;
                operation.@operator = Operator.ADD;

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

                // Add video campaigns.
                VideoCampaignReturnValue retval = videoCampaignService.mutate(operations);

                // Display video campaigns.
                if (retval != null && retval.value != null && retval.value.Length > 0)
                {
                    VideoCampaign newVideoCampaign = retval.value[0];
                    Console.WriteLine("Campaign with name '{0}' and id = {1} was added.",
                                      newVideoCampaign.name, newVideoCampaign.id);
                }
                else
                {
                    Console.WriteLine("No video campaigns were added.");
                }
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to add video campaign.", ex);
            }
        }