/// <summary> /// Creates the budget for the campaign. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <returns>The resource name of the newly created campaign budget.</returns> private static string CreateBudget(GoogleAdsClient client, long customerId) { // Get the BudgetService. CampaignBudgetServiceClient budgetService = client.GetService( Services.V4.CampaignBudgetService); // Create the campaign budget. CampaignBudget budget = new CampaignBudget() { Name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(), DeliveryMethod = BudgetDeliveryMethod.Standard, AmountMicros = 500000 }; // Create the operation. CampaignBudgetOperation budgetOperation = new CampaignBudgetOperation() { Create = budget }; // Create the campaign budget. MutateCampaignBudgetsResponse response = budgetService.MutateCampaignBudgets( customerId.ToString(), new CampaignBudgetOperation[] { budgetOperation }); return(response.Results[0].ResourceName); }
/// <summary> /// Creates a shared campaign budget to be used to create the campaign. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="name">The budget name.</param> /// <param name="amount">The budget amount in micros.</param> /// <returns>The budget resource name.</returns> private string CreateSharedBudget(GoogleAdsClient client, long customerId, string name, long amount) { // Get the CampaignBudgetService. CampaignBudgetServiceClient campaignBudgetService = client.GetService(Services.V1.CampaignBudgetService); // Create a shared budget. CampaignBudget budget = new CampaignBudget() { Name = name, AmountMicros = amount, DeliveryMethod = BudgetDeliveryMethodEnum.Types.BudgetDeliveryMethod.Standard, ExplicitlyShared = true }; // Create the operation. CampaignBudgetOperation campaignBudgetOperation = new CampaignBudgetOperation() { Create = budget }; // Make the mutate request. MutateCampaignBudgetsResponse retVal = campaignBudgetService.MutateCampaignBudgets( customerId.ToString(), new CampaignBudgetOperation[] { campaignBudgetOperation }); return(retVal.Results[0].ResourceName); }
/// <summary> /// Creates a new campaign budget in the specified client account. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <returns>The resource name of the newly created budget.</returns> private static string AddCampaignBudget(GoogleAdsClient client, long customerId) { // Get the CampaignBudgetService. CampaignBudgetServiceClient service = client.GetService( Services.V4.CampaignBudgetService); // Create a campaign budget. CampaignBudget budget = new CampaignBudget() { Name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(), DeliveryMethod = BudgetDeliveryMethod.Standard, AmountMicros = 50000000 }; // Create a campaign budget operation. CampaignBudgetOperation campaignBudgetOperation = new CampaignBudgetOperation() { Create = budget }; // Create the budget. MutateCampaignBudgetsResponse response = service.MutateCampaignBudgets( customerId.ToString(), new CampaignBudgetOperation[] { campaignBudgetOperation }); string budgetResourceName = response.Results[0].ResourceName; Console.WriteLine($"Added a budget with resource name: '{budgetResourceName}'."); return(budgetResourceName); }
/// <summary> /// Creates the budget for the campaign. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <returns>The resource name of the newly created campaign budget.</returns> private static string CreateBudget(GoogleAdsClient client, long customerId) { // Get the BudgetService. CampaignBudgetServiceClient budgetService = client.GetService( Services.V3.CampaignBudgetService); // Create the campaign budget. CampaignBudget budget = new CampaignBudget() { Name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(), DeliveryMethod = BudgetDeliveryMethod.Standard, AmountMicros = 500000 }; // Create the operation. CampaignBudgetOperation budgetOperation = new CampaignBudgetOperation() { Create = budget }; // Create the campaign budget. MutateCampaignBudgetsResponse response = budgetService.MutateCampaignBudgets( customerId.ToString(), new CampaignBudgetOperation[] { budgetOperation }); string budgetResourceName = response.Results.First().ResourceName; // Print out some information about the added budget. Console.WriteLine($"Added campaign budget with resource name = '{budgetResourceName}'."); return(budgetResourceName); }
/// <summary>Snippet for GetCampaignBudget</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCampaignBudget() { // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = CampaignBudgetServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/campaignBudgets/[CAMPAIGN_BUDGET_ID]"; // Make the request CampaignBudget response = campaignBudgetServiceClient.GetCampaignBudget(resourceName); }
/// <summary>Snippet for GetCampaignBudget</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCampaignBudgetResourceNames() { // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = CampaignBudgetServiceClient.Create(); // Initialize request argument(s) CampaignBudgetName resourceName = CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER]", "[CAMPAIGN_BUDGET]"); // Make the request CampaignBudget response = campaignBudgetServiceClient.GetCampaignBudget(resourceName); }
/// <summary>Snippet for GetCampaignBudgetAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetCampaignBudgetAsync() { // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = await CampaignBudgetServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/campaignBudgets/[CAMPAIGN_BUDGET]"; // Make the request CampaignBudget response = await campaignBudgetServiceClient.GetCampaignBudgetAsync(resourceName); }
/// <summary>Snippet for GetCampaignBudgetAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetCampaignBudgetResourceNamesAsync() { // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = await CampaignBudgetServiceClient.CreateAsync(); // Initialize request argument(s) CampaignBudgetName resourceName = CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"); // Make the request CampaignBudget response = await campaignBudgetServiceClient.GetCampaignBudgetAsync(resourceName); }
/// <summary>Snippet for GetCampaignBudget</summary> public void GetCampaignBudgetResourceNames() { // Snippet: GetCampaignBudget(CampaignBudgetName, CallSettings) // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = CampaignBudgetServiceClient.Create(); // Initialize request argument(s) CampaignBudgetName resourceName = CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"); // Make the request CampaignBudget response = campaignBudgetServiceClient.GetCampaignBudget(resourceName); // End snippet }
/// <summary>Snippet for GetCampaignBudget</summary> public void GetCampaignBudget() { // Snippet: GetCampaignBudget(string, CallSettings) // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = CampaignBudgetServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/campaignBudgets/[CAMPAIGN_BUDGET]"; // Make the request CampaignBudget response = campaignBudgetServiceClient.GetCampaignBudget(resourceName); // End snippet }
/// <summary>Snippet for GetCampaignBudget</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCampaignBudgetRequestObject() { // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = CampaignBudgetServiceClient.Create(); // Initialize request argument(s) GetCampaignBudgetRequest request = new GetCampaignBudgetRequest { ResourceNameAsCampaignBudgetName = CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"), }; // Make the request CampaignBudget response = campaignBudgetServiceClient.GetCampaignBudget(request); }
/// <summary>Snippet for GetCampaignBudgetAsync</summary> public async Task GetCampaignBudgetAsync() { // Snippet: GetCampaignBudgetAsync(string, CallSettings) // Additional: GetCampaignBudgetAsync(string, CancellationToken) // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = await CampaignBudgetServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/campaignBudgets/[CAMPAIGN_BUDGET_ID]"; // Make the request CampaignBudget response = await campaignBudgetServiceClient.GetCampaignBudgetAsync(resourceName); // End snippet }
/// <summary>Snippet for GetCampaignBudgetAsync</summary> public async Task GetCampaignBudgetResourceNamesAsync() { // Snippet: GetCampaignBudgetAsync(CampaignBudgetName, CallSettings) // Additional: GetCampaignBudgetAsync(CampaignBudgetName, CancellationToken) // Create client CampaignBudgetServiceClient campaignBudgetServiceClient = await CampaignBudgetServiceClient.CreateAsync(); // Initialize request argument(s) CampaignBudgetName resourceName = CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"); // Make the request CampaignBudget response = await campaignBudgetServiceClient.GetCampaignBudgetAsync(resourceName); // End snippet }
/// <summary> /// Creates the budget for the campaign. /// </summary> /// <param name="client">The Google Ads client.</param> /// <returns>The resource name of the newly created campaign budget.</returns> internal static string CreateBudget(GoogleAdsClient client) { CampaignBudget budget = new CampaignBudget() { Name = "Interplanetary Cruise Budget #" + ExampleUtilities.GetRandomString(), DeliveryMethod = BudgetDeliveryMethod.Standard, AmountMicros = 500000 }; MutateOperation mutateOperation = new MutateOperation() { CampaignBudgetOperation = new CampaignBudgetOperation() { Create = budget, }, }; return(ExecuteOperations(client, new[] { mutateOperation }).First() .CampaignBudgetResult.ResourceName); }
public void GetCampaignBudget2() { Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new Mock <CampaignBudgetService.CampaignBudgetServiceClient>(MockBehavior.Strict); GetCampaignBudgetRequest request = new GetCampaignBudgetRequest { ResourceName = new CampaignBudgetName("[CUSTOMER]", "[CAMPAIGN_BUDGET]").ToString(), }; CampaignBudget expectedResponse = new CampaignBudget { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetCampaignBudget(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CampaignBudgetServiceClient client = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null); CampaignBudget response = client.GetCampaignBudget(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetCampaignBudgetAsync2() { Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new Mock <CampaignBudgetService.CampaignBudgetServiceClient>(MockBehavior.Strict); GetCampaignBudgetRequest request = new GetCampaignBudgetRequest { ResourceName = new CampaignBudgetName("[CUSTOMER]", "[CAMPAIGN_BUDGET]").ToString(), }; CampaignBudget expectedResponse = new CampaignBudget { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetCampaignBudgetAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CampaignBudget>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignBudgetServiceClient client = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null); CampaignBudget response = await client.GetCampaignBudgetAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }