public async stt::Task GenerateForecastMetricsAsync() { moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict); GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlan = "keyword_plan348c505a", }; GenerateForecastMetricsResponse expectedResponse = new GenerateForecastMetricsResponse { CampaignForecasts = { new KeywordPlanCampaignForecast(), }, AdGroupForecasts = { new KeywordPlanAdGroupForecast(), }, KeywordForecasts = { new KeywordPlanKeywordForecast(), }, }; mockGrpcClient.Setup(x => x.GenerateForecastMetricsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateForecastMetricsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateForecastMetricsResponse responseCallSettings = await client.GenerateForecastMetricsAsync(request.KeywordPlan, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); GenerateForecastMetricsResponse responseCancellationToken = await client.GenerateForecastMetricsAsync(request.KeywordPlan, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GenerateForecastMetrics() { moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict); GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlan = "keyword_plan348c505a", }; GenerateForecastMetricsResponse expectedResponse = new GenerateForecastMetricsResponse { CampaignForecasts = { new KeywordPlanCampaignForecast(), }, AdGroupForecasts = { new KeywordPlanAdGroupForecast(), }, KeywordForecasts = { new KeywordPlanKeywordForecast(), }, }; mockGrpcClient.Setup(x => x.GenerateForecastMetrics(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateForecastMetricsResponse response = client.GenerateForecastMetrics(request.KeywordPlan); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GenerateForecastMetricsResourceNames() { moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict); GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlanAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"), }; GenerateForecastMetricsResponse expectedResponse = new GenerateForecastMetricsResponse { CampaignForecasts = { new KeywordPlanCampaignForecast(), }, AdGroupForecasts = { new KeywordPlanAdGroupForecast(), }, KeywordForecasts = { new KeywordPlanKeywordForecast(), }, }; mockGrpcClient.Setup(x => x.GenerateForecastMetrics(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateForecastMetricsResponse response = client.GenerateForecastMetrics(request.KeywordPlanAsKeywordPlanName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <param name="keywordPlanId">The keyword plan ID.</param> public void Run(GoogleAdsClient client, long customerId, long keywordPlanId) { KeywordPlanServiceClient kpServiceClient = client.GetService(Services.V5.KeywordPlanService); string keywordPlanResource = ResourceNames.KeywordPlan(customerId, keywordPlanId); try { GenerateForecastMetricsResponse response = kpServiceClient.GenerateForecastMetrics( keywordPlanResource); int i = 0; foreach (KeywordPlanKeywordForecast forecast in response.KeywordForecasts) { ForecastMetrics metrics = forecast.KeywordForecast; Console.WriteLine($"{++i}) Keyword ID: {forecast.KeywordPlanAdGroupKeyword}"); Console.WriteLine($"Estimated daily clicks: {metrics.Clicks}"); Console.WriteLine($"Estimated daily impressions: {metrics.Impressions}"); Console.WriteLine($"Estimated average cpc (micros): {metrics.AverageCpc}\n"); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
public async stt::Task GenerateForecastMetricsResourceNamesAsync() { moq::Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanService.KeywordPlanServiceClient>(moq::MockBehavior.Strict); GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlanAsKeywordPlanName = gagvr::KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"), }; GenerateForecastMetricsResponse expectedResponse = new GenerateForecastMetricsResponse { CampaignForecasts = { new KeywordPlanCampaignForecast(), }, AdGroupForecasts = { new KeywordPlanAdGroupForecast(), }, KeywordForecasts = { new KeywordPlanKeywordForecast(), }, }; mockGrpcClient.Setup(x => x.GenerateForecastMetricsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateForecastMetricsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateForecastMetricsResponse responseCallSettings = await client.GenerateForecastMetricsAsync(request.KeywordPlanAsKeywordPlanName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GenerateForecastMetricsResponse responseCancellationToken = await client.GenerateForecastMetricsAsync(request.KeywordPlanAsKeywordPlanName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GenerateForecastMetrics</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GenerateForecastMetricsResourceNames() { // Create client KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create(); // Initialize request argument(s) KeywordPlanName keywordPlan = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER_ID]", "[KEYWORD_PLAN_ID]"); // Make the request GenerateForecastMetricsResponse response = keywordPlanServiceClient.GenerateForecastMetrics(keywordPlan); }
/// <summary>Snippet for GenerateForecastMetrics</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GenerateForecastMetrics() { // Create client KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create(); // Initialize request argument(s) string keywordPlan = "customers/[CUSTOMER]/keywordPlans/[KEYWORD_PLAN]"; // Make the request GenerateForecastMetricsResponse response = keywordPlanServiceClient.GenerateForecastMetrics(keywordPlan); }
/// <summary>Snippet for GenerateForecastMetricsAsync</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 GenerateForecastMetricsResourceNamesAsync() { // Create client KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync(); // Initialize request argument(s) KeywordPlanName keywordPlan = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"); // Make the request GenerateForecastMetricsResponse response = await keywordPlanServiceClient.GenerateForecastMetricsAsync(keywordPlan); }
/// <summary>Snippet for GenerateForecastMetricsAsync</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 GenerateForecastMetricsAsync() { // Create client KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync(); // Initialize request argument(s) string keywordPlan = "customers/[CUSTOMER_ID]/keywordPlans/[KEYWORD_PLAN_ID]"; // Make the request GenerateForecastMetricsResponse response = await keywordPlanServiceClient.GenerateForecastMetricsAsync(keywordPlan); }
/// <summary>Snippet for GenerateForecastMetrics</summary> public void GenerateForecastMetrics() { // Snippet: GenerateForecastMetrics(string, CallSettings) // Create client KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create(); // Initialize request argument(s) string keywordPlan = "customers/[CUSTOMER_ID]/keywordPlans/[KEYWORD_PLAN_ID]"; // Make the request GenerateForecastMetricsResponse response = keywordPlanServiceClient.GenerateForecastMetrics(keywordPlan); // End snippet }
/// <summary>Snippet for GenerateForecastMetrics</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GenerateForecastMetricsRequestObject() { // Create client KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create(); // Initialize request argument(s) GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlanAsKeywordPlanName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"), }; // Make the request GenerateForecastMetricsResponse response = keywordPlanServiceClient.GenerateForecastMetrics(request); }
/// <summary>Snippet for GenerateForecastMetricsAsync</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 GenerateForecastMetricsRequestObjectAsync() { // Create client KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync(); // Initialize request argument(s) GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlanAsKeywordPlanName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER_ID]", "[KEYWORD_PLAN_ID]"), }; // Make the request GenerateForecastMetricsResponse response = await keywordPlanServiceClient.GenerateForecastMetricsAsync(request); }
/// <summary>Snippet for GenerateForecastMetricsAsync</summary> public async Task GenerateForecastMetricsResourceNamesAsync() { // Snippet: GenerateForecastMetricsAsync(KeywordPlanName, CallSettings) // Additional: GenerateForecastMetricsAsync(KeywordPlanName, CancellationToken) // Create client KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync(); // Initialize request argument(s) KeywordPlanName keywordPlan = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"); // Make the request GenerateForecastMetricsResponse response = await keywordPlanServiceClient.GenerateForecastMetricsAsync(keywordPlan); // End snippet }
/// <summary>Snippet for GenerateForecastMetricsAsync</summary> public async Task GenerateForecastMetricsAsync() { // Snippet: GenerateForecastMetricsAsync(string, CallSettings) // Additional: GenerateForecastMetricsAsync(string, CancellationToken) // Create client KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync(); // Initialize request argument(s) string keywordPlan = "customers/[CUSTOMER]/keywordPlans/[KEYWORD_PLAN]"; // Make the request GenerateForecastMetricsResponse response = await keywordPlanServiceClient.GenerateForecastMetricsAsync(keywordPlan); // End snippet }
/// <summary>Snippet for GenerateForecastMetricsAsync</summary> public async Task GenerateForecastMetricsRequestObjectAsync() { // Snippet: GenerateForecastMetricsAsync(GenerateForecastMetricsRequest, CallSettings) // Additional: GenerateForecastMetricsAsync(GenerateForecastMetricsRequest, CancellationToken) // Create client KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync(); // Initialize request argument(s) GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlanAsKeywordPlanName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"), }; // Make the request GenerateForecastMetricsResponse response = await keywordPlanServiceClient.GenerateForecastMetricsAsync(request); // End snippet }
public async Task GenerateForecastMetricsAsync2() { Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict); GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlan = new KeywordPlanName("[CUSTOMER]", "[KEYWORD_PLAN]").ToString(), }; GenerateForecastMetricsResponse expectedResponse = new GenerateForecastMetricsResponse(); mockGrpcClient.Setup(x => x.GenerateForecastMetricsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <GenerateForecastMetricsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateForecastMetricsResponse response = await client.GenerateForecastMetricsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GenerateForecastMetrics2() { Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict); GenerateForecastMetricsRequest request = new GenerateForecastMetricsRequest { KeywordPlan = new KeywordPlanName("[CUSTOMER]", "[KEYWORD_PLAN]").ToString(), }; GenerateForecastMetricsResponse expectedResponse = new GenerateForecastMetricsResponse(); mockGrpcClient.Setup(x => x.GenerateForecastMetrics(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateForecastMetricsResponse response = client.GenerateForecastMetrics(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }