Ejemplo n.º 1
0
        /// <summary>
        /// Creates the keyword plan.
        /// </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 newly created keyword plan resource.</returns>
        private string CreateKeywordPlan(GoogleAdsClient client, long customerId)
        {
            // Get the KeywordPlanService.
            KeywordPlanServiceClient serviceClient = client.GetService(
                Services.V6.KeywordPlanService);

            // Create a keyword plan for next quarter forecast.
            KeywordPlan keywordPlan = new KeywordPlan()
            {
                Name           = "Keyword plan for traffic estimate #" + ExampleUtilities.GetRandomString(),
                ForecastPeriod = new KeywordPlanForecastPeriod()
                {
                    DateInterval = KeywordPlanForecastInterval.NextQuarter
                }
            };

            KeywordPlanOperation operation = new KeywordPlanOperation()
            {
                Create = keywordPlan
            };

            // Add the keyword plan.
            MutateKeywordPlansResponse response = serviceClient.MutateKeywordPlans(
                customerId.ToString(), new KeywordPlanOperation[] { operation });

            // Display the results.
            String planResource = response.Results[0].ResourceName;

            Console.WriteLine($"Created keyword plan: {planResource}.");
            return(planResource);
        }
 /// <summary>Snippet for GetKeywordPlan</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetKeywordPlan()
 {
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER_ID]/keywordPlans/[KEYWORD_PLAN_ID]";
     // Make the request
     KeywordPlan response = keywordPlanServiceClient.GetKeywordPlan(resourceName);
 }
 /// <summary>Snippet for GetKeywordPlan</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetKeywordPlanResourceNames()
 {
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     KeywordPlanName resourceName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]");
     // Make the request
     KeywordPlan response = keywordPlanServiceClient.GetKeywordPlan(resourceName);
 }
Ejemplo n.º 4
0
        /// <summary>Snippet for GetKeywordPlanAsync</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 GetKeywordPlanAsync()
        {
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/keywordPlans/[KEYWORD_PLAN_ID]";
            // Make the request
            KeywordPlan response = await keywordPlanServiceClient.GetKeywordPlanAsync(resourceName);
        }
        /// <summary>Snippet for GetKeywordPlanAsync</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 GetKeywordPlanResourceNamesAsync()
        {
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            KeywordPlanName resourceName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER_ID]", "[KEYWORD_PLAN_ID]");
            // Make the request
            KeywordPlan response = await keywordPlanServiceClient.GetKeywordPlanAsync(resourceName);
        }
Ejemplo n.º 6
0
 /// <summary>Snippet for GetKeywordPlan</summary>
 public void GetKeywordPlan()
 {
     // Snippet: GetKeywordPlan(string, CallSettings)
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER]/keywordPlans/[KEYWORD_PLAN]";
     // Make the request
     KeywordPlan response = keywordPlanServiceClient.GetKeywordPlan(resourceName);
     // End snippet
 }
Ejemplo n.º 7
0
 /// <summary>Snippet for GetKeywordPlan</summary>
 public void GetKeywordPlanResourceNames()
 {
     // Snippet: GetKeywordPlan(KeywordPlanName, CallSettings)
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     KeywordPlanName resourceName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER_ID]", "[KEYWORD_PLAN_ID]");
     // Make the request
     KeywordPlan response = keywordPlanServiceClient.GetKeywordPlan(resourceName);
     // End snippet
 }
 /// <summary>Snippet for GetKeywordPlan</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetKeywordPlanRequestObject()
 {
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     GetKeywordPlanRequest request = new GetKeywordPlanRequest
     {
         ResourceNameAsKeywordPlanName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER_ID]", "[KEYWORD_PLAN_ID]"),
     };
     // Make the request
     KeywordPlan response = keywordPlanServiceClient.GetKeywordPlan(request);
 }
Ejemplo n.º 9
0
        /// <summary>Snippet for GetKeywordPlanAsync</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 GetKeywordPlanRequestObjectAsync()
        {
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetKeywordPlanRequest request = new GetKeywordPlanRequest
            {
                ResourceNameAsKeywordPlanName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]"),
            };
            // Make the request
            KeywordPlan response = await keywordPlanServiceClient.GetKeywordPlanAsync(request);
        }
Ejemplo n.º 10
0
        /// <summary>Snippet for GetKeywordPlanAsync</summary>
        public async Task GetKeywordPlanAsync()
        {
            // Snippet: GetKeywordPlanAsync(string, CallSettings)
            // Additional: GetKeywordPlanAsync(string, CancellationToken)
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER]/keywordPlans/[KEYWORD_PLAN]";
            // Make the request
            KeywordPlan response = await keywordPlanServiceClient.GetKeywordPlanAsync(resourceName);

            // End snippet
        }
Ejemplo n.º 11
0
        /// <summary>Snippet for GetKeywordPlanAsync</summary>
        public async Task GetKeywordPlanResourceNamesAsync()
        {
            // Snippet: GetKeywordPlanAsync(KeywordPlanName, CallSettings)
            // Additional: GetKeywordPlanAsync(KeywordPlanName, CancellationToken)
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            KeywordPlanName resourceName = KeywordPlanName.FromCustomerKeywordPlan("[CUSTOMER]", "[KEYWORD_PLAN]");
            // Make the request
            KeywordPlan response = await keywordPlanServiceClient.GetKeywordPlanAsync(resourceName);

            // End snippet
        }
        public void GetKeywordPlan2()
        {
            Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict);
            GetKeywordPlanRequest request = new GetKeywordPlanRequest
            {
                ResourceName = new KeywordPlanName("[CUSTOMER]", "[KEYWORD_PLAN]").ToString(),
            };
            KeywordPlan expectedResponse = new KeywordPlan
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetKeywordPlan(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            KeywordPlan response            = client.GetKeywordPlan(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetKeywordPlanAsync2()
        {
            Mock <KeywordPlanService.KeywordPlanServiceClient> mockGrpcClient = new Mock <KeywordPlanService.KeywordPlanServiceClient>(MockBehavior.Strict);
            GetKeywordPlanRequest request = new GetKeywordPlanRequest
            {
                ResourceName = new KeywordPlanName("[CUSTOMER]", "[KEYWORD_PLAN]").ToString(),
            };
            KeywordPlan expectedResponse = new KeywordPlan
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetKeywordPlanAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <KeywordPlan>(Task.FromResult(expectedResponse), null, null, null, null));
            KeywordPlanServiceClient client = new KeywordPlanServiceClientImpl(mockGrpcClient.Object, null);
            KeywordPlan response            = await client.GetKeywordPlanAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }