/// <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); } }