public async stt::Task MutateKeywordPlanAdGroupKeywordsAsync()
        {
            moq::Mock <KeywordPlanAdGroupKeywordService.KeywordPlanAdGroupKeywordServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanAdGroupKeywordService.KeywordPlanAdGroupKeywordServiceClient>(moq::MockBehavior.Strict);
            MutateKeywordPlanAdGroupKeywordsRequest request = new MutateKeywordPlanAdGroupKeywordsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new KeywordPlanAdGroupKeywordOperation(),
                },
            };
            MutateKeywordPlanAdGroupKeywordsResponse expectedResponse = new MutateKeywordPlanAdGroupKeywordsResponse
            {
                Results =
                {
                    new MutateKeywordPlanAdGroupKeywordResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateKeywordPlanAdGroupKeywordsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateKeywordPlanAdGroupKeywordsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            KeywordPlanAdGroupKeywordServiceClient   client = new KeywordPlanAdGroupKeywordServiceClientImpl(mockGrpcClient.Object, null);
            MutateKeywordPlanAdGroupKeywordsResponse responseCallSettings = await client.MutateKeywordPlanAdGroupKeywordsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            MutateKeywordPlanAdGroupKeywordsResponse responseCancellationToken = await client.MutateKeywordPlanAdGroupKeywordsAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void MutateKeywordPlanAdGroupKeywords()
        {
            moq::Mock <KeywordPlanAdGroupKeywordService.KeywordPlanAdGroupKeywordServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanAdGroupKeywordService.KeywordPlanAdGroupKeywordServiceClient>(moq::MockBehavior.Strict);
            MutateKeywordPlanAdGroupKeywordsRequest request = new MutateKeywordPlanAdGroupKeywordsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new KeywordPlanAdGroupKeywordOperation(),
                },
            };
            MutateKeywordPlanAdGroupKeywordsResponse expectedResponse = new MutateKeywordPlanAdGroupKeywordsResponse
            {
                Results =
                {
                    new MutateKeywordPlanAdGroupKeywordResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateKeywordPlanAdGroupKeywords(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            KeywordPlanAdGroupKeywordServiceClient   client   = new KeywordPlanAdGroupKeywordServiceClientImpl(mockGrpcClient.Object, null);
            MutateKeywordPlanAdGroupKeywordsResponse response = client.MutateKeywordPlanAdGroupKeywords(request.CustomerId, request.Operations);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for MutateKeywordPlanAdGroupKeywords</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlanAdGroupKeywords()
 {
     // Create client
     KeywordPlanAdGroupKeywordServiceClient keywordPlanAdGroupKeywordServiceClient = KeywordPlanAdGroupKeywordServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <KeywordPlanAdGroupKeywordOperation> operations = new KeywordPlanAdGroupKeywordOperation[]
     {
         new KeywordPlanAdGroupKeywordOperation(),
     };
     // Make the request
     MutateKeywordPlanAdGroupKeywordsResponse response = keywordPlanAdGroupKeywordServiceClient.MutateKeywordPlanAdGroupKeywords(customerId, operations);
 }
 /// <summary>Snippet for MutateKeywordPlanAdGroupKeywords</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlanAdGroupKeywordsRequestObject()
 {
     // Create client
     KeywordPlanAdGroupKeywordServiceClient keywordPlanAdGroupKeywordServiceClient = KeywordPlanAdGroupKeywordServiceClient.Create();
     // Initialize request argument(s)
     MutateKeywordPlanAdGroupKeywordsRequest request = new MutateKeywordPlanAdGroupKeywordsRequest
     {
         CustomerId = "",
         Operations =
         {
             new KeywordPlanAdGroupKeywordOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateKeywordPlanAdGroupKeywordsResponse response = keywordPlanAdGroupKeywordServiceClient.MutateKeywordPlanAdGroupKeywords(request);
 }
        /// <summary>Snippet for MutateKeywordPlanAdGroupKeywordsAsync</summary>
        public async Task MutateKeywordPlanAdGroupKeywordsAsync()
        {
            // Snippet: MutateKeywordPlanAdGroupKeywordsAsync(string, IEnumerable<KeywordPlanAdGroupKeywordOperation>, CallSettings)
            // Additional: MutateKeywordPlanAdGroupKeywordsAsync(string, IEnumerable<KeywordPlanAdGroupKeywordOperation>, CancellationToken)
            // Create client
            KeywordPlanAdGroupKeywordServiceClient keywordPlanAdGroupKeywordServiceClient = await KeywordPlanAdGroupKeywordServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <KeywordPlanAdGroupKeywordOperation> operations = new KeywordPlanAdGroupKeywordOperation[]
            {
                new KeywordPlanAdGroupKeywordOperation(),
            };
            // Make the request
            MutateKeywordPlanAdGroupKeywordsResponse response = await keywordPlanAdGroupKeywordServiceClient.MutateKeywordPlanAdGroupKeywordsAsync(customerId, operations);

            // End snippet
        }
        /// <summary>Snippet for MutateKeywordPlanAdGroupKeywordsAsync</summary>
        public async Task MutateKeywordPlanAdGroupKeywordsRequestObjectAsync()
        {
            // Snippet: MutateKeywordPlanAdGroupKeywordsAsync(MutateKeywordPlanAdGroupKeywordsRequest, CallSettings)
            // Additional: MutateKeywordPlanAdGroupKeywordsAsync(MutateKeywordPlanAdGroupKeywordsRequest, CancellationToken)
            // Create client
            KeywordPlanAdGroupKeywordServiceClient keywordPlanAdGroupKeywordServiceClient = await KeywordPlanAdGroupKeywordServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateKeywordPlanAdGroupKeywordsRequest request = new MutateKeywordPlanAdGroupKeywordsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new KeywordPlanAdGroupKeywordOperation(),
                },
                PartialFailure = false,
                ValidateOnly   = false,
            };
            // Make the request
            MutateKeywordPlanAdGroupKeywordsResponse response = await keywordPlanAdGroupKeywordServiceClient.MutateKeywordPlanAdGroupKeywordsAsync(request);

            // End snippet
        }
예제 #7
0
        /// <summary>
        /// Creates keywords for 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>
        /// <param name="planAdGroupResource">The resource name of the ad group under which the
        /// keyword is created.</param>
        private static void CreateKeywordPlanAdGroupKeywords(GoogleAdsClient client,
                                                             long customerId, string planAdGroupResource)
        {
            // Get the KeywordPlanAdGroupKeywordService.
            KeywordPlanAdGroupKeywordServiceClient serviceClient = client.GetService(
                Services.V6.KeywordPlanAdGroupKeywordService);

            // Create the adgroup level keywords for keyword plan.
            KeywordPlanAdGroupKeyword kpAdGroupKeyword1 = new KeywordPlanAdGroupKeyword()
            {
                KeywordPlanAdGroup = planAdGroupResource,
                CpcBidMicros       = 2_000_000L,
                MatchType          = KeywordMatchType.Broad,
                Text = "mars cruise"
            };

            KeywordPlanAdGroupKeyword kpAdGroupKeyword2 = new KeywordPlanAdGroupKeyword()
            {
                KeywordPlanAdGroup = planAdGroupResource,
                CpcBidMicros       = 1_500_000L,
                MatchType          = KeywordMatchType.Phrase,
                Text = "cheap cruise"
            };

            KeywordPlanAdGroupKeyword kpAdGroupKeyword3 = new KeywordPlanAdGroupKeyword()
            {
                KeywordPlanAdGroup = planAdGroupResource,
                CpcBidMicros       = 1_990_000L,
                MatchType          = KeywordMatchType.Exact,
                Text = "jupiter cruise"
            };

            KeywordPlanAdGroupKeyword[] kpAdGroupKeywords = new KeywordPlanAdGroupKeyword[]
            {
                kpAdGroupKeyword1,
                kpAdGroupKeyword2,
                kpAdGroupKeyword3
            };

            // Create an operation for each plan keyword.
            List <KeywordPlanAdGroupKeywordOperation> operations =
                new List <KeywordPlanAdGroupKeywordOperation>();

            foreach (KeywordPlanAdGroupKeyword kpAdGroupKeyword in kpAdGroupKeywords)
            {
                operations.Add(new KeywordPlanAdGroupKeywordOperation
                {
                    Create = kpAdGroupKeyword
                });
            }

            // Add the keywords.
            MutateKeywordPlanAdGroupKeywordsResponse response =
                serviceClient.MutateKeywordPlanAdGroupKeywords(customerId.ToString(), operations);

            // Display the results.
            foreach (MutateKeywordPlanAdGroupKeywordResult result in response.Results)
            {
                Console.WriteLine(
                    $"Created ad group keyword for keyword plan: {result.ResourceName}.");
            }
            return;
        }