Example #1
0
        public async stt::Task MutateCustomerNegativeCriteriaAsync()
        {
            moq::Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient> mockGrpcClient = new moq::Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient>(moq::MockBehavior.Strict);
            MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomerNegativeCriterionOperation(),
                },
            };
            MutateCustomerNegativeCriteriaResponse expectedResponse = new MutateCustomerNegativeCriteriaResponse
            {
                Results =
                {
                    new MutateCustomerNegativeCriteriaResult(),
                },
                PartialFailureError = new gr::Status(),
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            MutateCustomerNegativeCriteriaResponse responseCancellationToken = await client.MutateCustomerNegativeCriteriaAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void MutateCustomerNegativeCriteriaRequestObject()
        {
            moq::Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient> mockGrpcClient = new moq::Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient>(moq::MockBehavior.Strict);
            MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomerNegativeCriterionOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = true,
                ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly,
            };
            MutateCustomerNegativeCriteriaResponse expectedResponse = new MutateCustomerNegativeCriteriaResponse
            {
                Results =
                {
                    new MutateCustomerNegativeCriteriaResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCustomerNegativeCriteria(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CustomerNegativeCriterionServiceClient client   = new CustomerNegativeCriterionServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerNegativeCriteriaResponse response = client.MutateCustomerNegativeCriteria(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #3
0
        public void MutateCustomerNegativeCriteria()
        {
            moq::Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient> mockGrpcClient = new moq::Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient>(moq::MockBehavior.Strict);
            MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomerNegativeCriterionOperation(),
                },
            };
            MutateCustomerNegativeCriteriaResponse expectedResponse = new MutateCustomerNegativeCriteriaResponse
            {
                Results =
                {
                    new MutateCustomerNegativeCriteriaResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCustomerNegativeCriteria(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CustomerNegativeCriterionServiceClient client   = new CustomerNegativeCriterionServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerNegativeCriteriaResponse response = client.MutateCustomerNegativeCriteria(request.CustomerId, request.Operations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for MutateCustomerNegativeCriteria</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateCustomerNegativeCriteria()
 {
     // Create client
     CustomerNegativeCriterionServiceClient customerNegativeCriterionServiceClient = CustomerNegativeCriterionServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <CustomerNegativeCriterionOperation> operations = new CustomerNegativeCriterionOperation[]
     {
         new CustomerNegativeCriterionOperation(),
     };
     // Make the request
     MutateCustomerNegativeCriteriaResponse response = customerNegativeCriterionServiceClient.MutateCustomerNegativeCriteria(customerId, operations);
 }
        public async Task MutateCustomerNegativeCriteriaAsync3()
        {
            Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient> mockGrpcClient = new Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient>(MockBehavior.Strict);
            MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCustomerNegativeCriteriaResponse expectedResponse = new MutateCustomerNegativeCriteriaResponse();

            mockGrpcClient.Setup(x => x.MutateCustomerNegativeCriteriaAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCustomerNegativeCriteriaResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CustomerNegativeCriterionServiceClient client   = new CustomerNegativeCriterionServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerNegativeCriteriaResponse response = await client.MutateCustomerNegativeCriteriaAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void MutateCustomerNegativeCriteria3()
        {
            Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient> mockGrpcClient = new Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient>(MockBehavior.Strict);
            MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCustomerNegativeCriteriaResponse expectedResponse = new MutateCustomerNegativeCriteriaResponse();

            mockGrpcClient.Setup(x => x.MutateCustomerNegativeCriteria(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CustomerNegativeCriterionServiceClient client   = new CustomerNegativeCriterionServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomerNegativeCriteriaResponse response = client.MutateCustomerNegativeCriteria(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #7
0
        /// <summary>Snippet for MutateCustomerNegativeCriteriaAsync</summary>
        public async Task MutateCustomerNegativeCriteriaAsync()
        {
            // Snippet: MutateCustomerNegativeCriteriaAsync(string, IEnumerable<CustomerNegativeCriterionOperation>, CallSettings)
            // Additional: MutateCustomerNegativeCriteriaAsync(string, IEnumerable<CustomerNegativeCriterionOperation>, CancellationToken)
            // Create client
            CustomerNegativeCriterionServiceClient customerNegativeCriterionServiceClient = await CustomerNegativeCriterionServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <CustomerNegativeCriterionOperation> operations = new CustomerNegativeCriterionOperation[]
            {
                new CustomerNegativeCriterionOperation(),
            };
            // Make the request
            MutateCustomerNegativeCriteriaResponse response = await customerNegativeCriterionServiceClient.MutateCustomerNegativeCriteriaAsync(customerId, operations);

            // End snippet
        }
Example #8
0
 /// <summary>Snippet for MutateCustomerNegativeCriteria</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateCustomerNegativeCriteriaRequestObject()
 {
     // Create client
     CustomerNegativeCriterionServiceClient customerNegativeCriterionServiceClient = CustomerNegativeCriterionServiceClient.Create();
     // Initialize request argument(s)
     MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
     {
         CustomerId = "",
         Operations =
         {
             new CustomerNegativeCriterionOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateCustomerNegativeCriteriaResponse response = customerNegativeCriterionServiceClient.MutateCustomerNegativeCriteria(request);
 }
        /// <summary>Snippet for MutateCustomerNegativeCriteriaAsync</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 MutateCustomerNegativeCriteriaRequestObjectAsync()
        {
            // Create client
            CustomerNegativeCriterionServiceClient customerNegativeCriterionServiceClient = await CustomerNegativeCriterionServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId = "",
                Operations =
                {
                    new CustomerNegativeCriterionOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = false,
                ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
            };
            // Make the request
            MutateCustomerNegativeCriteriaResponse response = await customerNegativeCriterionServiceClient.MutateCustomerNegativeCriteriaAsync(request);
        }
Example #10
0
 /// <summary>Snippet for MutateCustomerNegativeCriteria</summary>
 public void MutateCustomerNegativeCriteriaRequestObject()
 {
     // Snippet: MutateCustomerNegativeCriteria(MutateCustomerNegativeCriteriaRequest, CallSettings)
     // Create client
     CustomerNegativeCriterionServiceClient customerNegativeCriterionServiceClient = CustomerNegativeCriterionServiceClient.Create();
     // Initialize request argument(s)
     MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
     {
         CustomerId = "",
         Operations =
         {
             new CustomerNegativeCriterionOperation(),
         },
         PartialFailure      = false,
         ValidateOnly        = false,
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateCustomerNegativeCriteriaResponse response = customerNegativeCriterionServiceClient.MutateCustomerNegativeCriteria(request);
     // End snippet
 }
        /// <summary>Snippet for MutateCustomerNegativeCriteriaAsync</summary>
        public async Task MutateCustomerNegativeCriteriaRequestObjectAsync()
        {
            // Snippet: MutateCustomerNegativeCriteriaAsync(MutateCustomerNegativeCriteriaRequest, CallSettings)
            // Additional: MutateCustomerNegativeCriteriaAsync(MutateCustomerNegativeCriteriaRequest, CancellationToken)
            // Create client
            CustomerNegativeCriterionServiceClient customerNegativeCriterionServiceClient = await CustomerNegativeCriterionServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateCustomerNegativeCriteriaRequest request = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId = "",
                Operations =
                {
                    new CustomerNegativeCriterionOperation(),
                },
                PartialFailure = false,
                ValidateOnly   = false,
            };
            // Make the request
            MutateCustomerNegativeCriteriaResponse response = await customerNegativeCriterionServiceClient.MutateCustomerNegativeCriteriaAsync(request);

            // End snippet
        }
        public async Task MutateCustomerNegativeCriteriaAsync()
        {
            Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient> mockGrpcClient = new Mock <CustomerNegativeCriterionService.CustomerNegativeCriterionServiceClient>(MockBehavior.Strict);
            MutateCustomerNegativeCriteriaRequest expectedRequest = new MutateCustomerNegativeCriteriaRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateCustomerNegativeCriteriaResponse expectedResponse = new MutateCustomerNegativeCriteriaResponse();

            mockGrpcClient.Setup(x => x.MutateCustomerNegativeCriteriaAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCustomerNegativeCriteriaResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CustomerNegativeCriterionServiceClient client = new CustomerNegativeCriterionServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            IEnumerable <CustomerNegativeCriterionOperation> operations = new List <CustomerNegativeCriterionOperation>();
            bool partialFailure = true;
            bool validateOnly   = false;
            MutateCustomerNegativeCriteriaResponse response = await client.MutateCustomerNegativeCriteriaAsync(customerId, operations, partialFailure, validateOnly);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        public void Run(GoogleAdsClient client, long customerId)
        {
            // Get the CustomerNegativeCriterionServiceClient .
            CustomerNegativeCriterionServiceClient customerNegativeCriterionService =
                client.GetService(Services.V3.CustomerNegativeCriterionService);

            // Creates a negative customer criterion excluding the content label type of 'TRAGEDY'.
            CustomerNegativeCriterion tragedyCriterion = new CustomerNegativeCriterion()
            {
                ContentLabel = new ContentLabelInfo()
                {
                    Type = ContentLabelType.Tragedy
                }
            };

            // Creates a negative customer criterion excluding the placement with URL
            // 'http://www.example.com'.
            CustomerNegativeCriterion placementCriterion = new CustomerNegativeCriterion()
            {
                Placement = new PlacementInfo()
                {
                    Url = "http://www.example.com"
                }
            };

            // Creates the operations.
            CustomerNegativeCriterionOperation tragedyCriterionOperation =
                new CustomerNegativeCriterionOperation()
            {
                Create = tragedyCriterion
            };

            CustomerNegativeCriterionOperation placementCriterionOperation =
                new CustomerNegativeCriterionOperation()
            {
                Create = placementCriterion
            };

            try
            {
                // Adds the negative customer criteria.
                MutateCustomerNegativeCriteriaResponse response =
                    customerNegativeCriterionService.MutateCustomerNegativeCriteria(
                        customerId.ToString(), new CustomerNegativeCriterionOperation[]
                        { tragedyCriterionOperation, placementCriterionOperation });

                // Displays the results.
                Console.WriteLine($"Created {response.Results.Count} new negative customer " +
                                  $"criteria.");

                foreach (MutateCustomerNegativeCriteriaResult result in response.Results)
                {
                    Console.WriteLine($"Created new negative customer criteria with resource " +
                                      $"name '{result.ResourceName}'.");
                }
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }