public void MutateKeywordPlanCampaignKeywords() { moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient>(moq::MockBehavior.Strict); MutateKeywordPlanCampaignKeywordsRequest request = new MutateKeywordPlanCampaignKeywordsRequest { CustomerId = "customer_id3b3724cb", Operations = { new KeywordPlanCampaignKeywordOperation(), }, }; MutateKeywordPlanCampaignKeywordsResponse expectedResponse = new MutateKeywordPlanCampaignKeywordsResponse { Results = { new MutateKeywordPlanCampaignKeywordResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateKeywordPlanCampaignKeywords(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); KeywordPlanCampaignKeywordServiceClient client = new KeywordPlanCampaignKeywordServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanCampaignKeywordsResponse response = client.MutateKeywordPlanCampaignKeywords(request.CustomerId, request.Operations); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateKeywordPlanCampaignKeywordsAsync() { moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient> mockGrpcClient = new moq::Mock <KeywordPlanCampaignKeywordService.KeywordPlanCampaignKeywordServiceClient>(moq::MockBehavior.Strict); MutateKeywordPlanCampaignKeywordsRequest request = new MutateKeywordPlanCampaignKeywordsRequest { CustomerId = "customer_id3b3724cb", Operations = { new KeywordPlanCampaignKeywordOperation(), }, }; MutateKeywordPlanCampaignKeywordsResponse expectedResponse = new MutateKeywordPlanCampaignKeywordsResponse { Results = { new MutateKeywordPlanCampaignKeywordResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateKeywordPlanCampaignKeywordsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateKeywordPlanCampaignKeywordsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); KeywordPlanCampaignKeywordServiceClient client = new KeywordPlanCampaignKeywordServiceClientImpl(mockGrpcClient.Object, null); MutateKeywordPlanCampaignKeywordsResponse responseCallSettings = await client.MutateKeywordPlanCampaignKeywordsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); MutateKeywordPlanCampaignKeywordsResponse responseCancellationToken = await client.MutateKeywordPlanCampaignKeywordsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Creates campaign negative keywords for the keyword plan. /// </summary> /// <param name="client">he Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="planCampaignResource">The resource name of the campaign under which the /// negative keyword is created.</param> private static void CreateKeywordPlanCampaignNegativeKeywords(GoogleAdsClient client, long customerId, string planCampaignResource) { // Get the KeywordPlanCampaignKeywordService. KeywordPlanCampaignKeywordServiceClient service = client.GetService( Services.V6.KeywordPlanCampaignKeywordService); // Create the campaign negative keyword for the keyword plan. KeywordPlanCampaignKeyword kpCampaignNegativeKeyword = new KeywordPlanCampaignKeyword() { KeywordPlanCampaign = planCampaignResource, MatchType = KeywordMatchType.Broad, Text = "moon walk", Negative = true }; KeywordPlanCampaignKeywordOperation operation = new KeywordPlanCampaignKeywordOperation { Create = kpCampaignNegativeKeyword }; // Add the campaign negative keyword. MutateKeywordPlanCampaignKeywordsResponse response = service.MutateKeywordPlanCampaignKeywords(customerId.ToString(), new KeywordPlanCampaignKeywordOperation[] { operation }); // Display the result. MutateKeywordPlanCampaignKeywordResult result = response.Results[0]; Console.WriteLine("Created campaign negative keyword for keyword plan: " + $"{result.ResourceName}."); return; }
/// <summary>Snippet for MutateKeywordPlanCampaignKeywords</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateKeywordPlanCampaignKeywords() { // Create client KeywordPlanCampaignKeywordServiceClient keywordPlanCampaignKeywordServiceClient = KeywordPlanCampaignKeywordServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanCampaignKeywordOperation> operations = new KeywordPlanCampaignKeywordOperation[] { new KeywordPlanCampaignKeywordOperation(), }; // Make the request MutateKeywordPlanCampaignKeywordsResponse response = keywordPlanCampaignKeywordServiceClient.MutateKeywordPlanCampaignKeywords(customerId, operations); }
/// <summary>Snippet for MutateKeywordPlanCampaignKeywordsAsync</summary> public async Task MutateKeywordPlanCampaignKeywordsAsync() { // Snippet: MutateKeywordPlanCampaignKeywordsAsync(string, IEnumerable<KeywordPlanCampaignKeywordOperation>, CallSettings) // Additional: MutateKeywordPlanCampaignKeywordsAsync(string, IEnumerable<KeywordPlanCampaignKeywordOperation>, CancellationToken) // Create client KeywordPlanCampaignKeywordServiceClient keywordPlanCampaignKeywordServiceClient = await KeywordPlanCampaignKeywordServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanCampaignKeywordOperation> operations = new KeywordPlanCampaignKeywordOperation[] { new KeywordPlanCampaignKeywordOperation(), }; // Make the request MutateKeywordPlanCampaignKeywordsResponse response = await keywordPlanCampaignKeywordServiceClient.MutateKeywordPlanCampaignKeywordsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateKeywordPlanCampaignKeywords</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateKeywordPlanCampaignKeywordsRequestObject() { // Create client KeywordPlanCampaignKeywordServiceClient keywordPlanCampaignKeywordServiceClient = KeywordPlanCampaignKeywordServiceClient.Create(); // Initialize request argument(s) MutateKeywordPlanCampaignKeywordsRequest request = new MutateKeywordPlanCampaignKeywordsRequest { CustomerId = "", Operations = { new KeywordPlanCampaignKeywordOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateKeywordPlanCampaignKeywordsResponse response = keywordPlanCampaignKeywordServiceClient.MutateKeywordPlanCampaignKeywords(request); }
/// <summary>Snippet for MutateKeywordPlanCampaignKeywordsAsync</summary> public async Task MutateKeywordPlanCampaignKeywordsRequestObjectAsync() { // Snippet: MutateKeywordPlanCampaignKeywordsAsync(MutateKeywordPlanCampaignKeywordsRequest, CallSettings) // Additional: MutateKeywordPlanCampaignKeywordsAsync(MutateKeywordPlanCampaignKeywordsRequest, CancellationToken) // Create client KeywordPlanCampaignKeywordServiceClient keywordPlanCampaignKeywordServiceClient = await KeywordPlanCampaignKeywordServiceClient.CreateAsync(); // Initialize request argument(s) MutateKeywordPlanCampaignKeywordsRequest request = new MutateKeywordPlanCampaignKeywordsRequest { CustomerId = "", Operations = { new KeywordPlanCampaignKeywordOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateKeywordPlanCampaignKeywordsResponse response = await keywordPlanCampaignKeywordServiceClient.MutateKeywordPlanCampaignKeywordsAsync(request); // End snippet }