Ejemplo n.º 1
0
        public async stt::Task MutateCustomAudiencesAsync()
        {
            moq::Mock <CustomAudienceService.CustomAudienceServiceClient> mockGrpcClient = new moq::Mock <CustomAudienceService.CustomAudienceServiceClient>(moq::MockBehavior.Strict);
            MutateCustomAudiencesRequest request = new MutateCustomAudiencesRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomAudienceOperation(),
                },
            };
            MutateCustomAudiencesResponse expectedResponse = new MutateCustomAudiencesResponse
            {
                Results =
                {
                    new MutateCustomAudienceResult(),
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void MutateCustomAudiences()
        {
            moq::Mock <CustomAudienceService.CustomAudienceServiceClient> mockGrpcClient = new moq::Mock <CustomAudienceService.CustomAudienceServiceClient>(moq::MockBehavior.Strict);
            MutateCustomAudiencesRequest request = new MutateCustomAudiencesRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CustomAudienceOperation(),
                },
            };
            MutateCustomAudiencesResponse expectedResponse = new MutateCustomAudiencesResponse
            {
                Results =
                {
                    new MutateCustomAudienceResult(),
                },
            };

            mockGrpcClient.Setup(x => x.MutateCustomAudiences(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CustomAudienceServiceClient   client   = new CustomAudienceServiceClientImpl(mockGrpcClient.Object, null);
            MutateCustomAudiencesResponse response = client.MutateCustomAudiences(request.CustomerId, request.Operations);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 3
0
        /// <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 conversion action is
        /// added.</param>
        public void Run(GoogleAdsClient client, long customerId)
        {
            // Get the CustomAudienceService client.
            CustomAudienceServiceClient customAudienceServiceClient =
                client.GetService(Services.V10.CustomAudienceService);

            // Create a custom audience.
            CustomAudience customAudience = new CustomAudience
            {
                Name        = $"Example CustomAudience #{ExampleUtilities.GetRandomString()}",
                Description = "Custom audiences who have searched specific terms on Google Search",
                // Match customers by what they searched on Google Search.
                // Note: "INTEREST" OR "PURCHASE_INTENT" is not allowed for the type field of newly
                // created custom audience. Use "AUTO" instead of these 2 options when creating a
                // new custom audience.
                Type   = CustomAudienceType.Search,
                Status = CustomAudienceStatus.Enabled,
            };

            // Add custom audience members to the custom audience. Customers that meet any of the
            // membership conditions will be reached.
            // Keywords or keyword phrases, which describe the customers' interests or search terms.
            customAudience.Members.Add(CreateCustomAudienceMember(CustomAudienceMemberType.Keyword,
                                                                  "mars cruise"));
            customAudience.Members.Add(CreateCustomAudienceMember(CustomAudienceMemberType.Keyword,
                                                                  "jupiter cruise"));
            // Website URLs that your customers might visit.
            customAudience.Members.Add(CreateCustomAudienceMember(CustomAudienceMemberType.Url,
                                                                  "http://www.example.com/locations/mars"));
            customAudience.Members.Add(CreateCustomAudienceMember(CustomAudienceMemberType.Url,
                                                                  "http://www.example.com/locations/jupiter"));
            // Package names of Android apps which customers might install.
            customAudience.Members.Add(CreateCustomAudienceMember(CustomAudienceMemberType.App,
                                                                  "com.google.android.apps.adwords"));

            // Create a custom audience operation.
            CustomAudienceOperation customAudienceOperation = new CustomAudienceOperation
            {
                Create = customAudience
            };

            try
            {
                // Add the custom audience and display the results.
                MutateCustomAudiencesResponse customAudiencesResponse = customAudienceServiceClient
                                                                        .MutateCustomAudiences(customerId.ToString(), new[] { customAudienceOperation });

                Console.WriteLine("New custom audience added with resource name: " +
                                  $"'{customAudiencesResponse.Results.First().ResourceName}'.");
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
Ejemplo n.º 4
0
 /// <summary>Snippet for MutateCustomAudiences</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateCustomAudiences()
 {
     // Create client
     CustomAudienceServiceClient customAudienceServiceClient = CustomAudienceServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <CustomAudienceOperation> operations = new CustomAudienceOperation[]
     {
         new CustomAudienceOperation(),
     };
     // Make the request
     MutateCustomAudiencesResponse response = customAudienceServiceClient.MutateCustomAudiences(customerId, operations);
 }
 /// <summary>Snippet for MutateCustomAudiences</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateCustomAudiencesRequestObject()
 {
     // Create client
     CustomAudienceServiceClient customAudienceServiceClient = CustomAudienceServiceClient.Create();
     // Initialize request argument(s)
     MutateCustomAudiencesRequest request = new MutateCustomAudiencesRequest
     {
         CustomerId = "",
         Operations =
         {
             new CustomAudienceOperation(),
         },
         ValidateOnly = false,
     };
     // Make the request
     MutateCustomAudiencesResponse response = customAudienceServiceClient.MutateCustomAudiences(request);
 }
Ejemplo n.º 6
0
        /// <summary>Snippet for MutateCustomAudiencesAsync</summary>
        public async Task MutateCustomAudiencesAsync()
        {
            // Snippet: MutateCustomAudiencesAsync(string, IEnumerable<CustomAudienceOperation>, CallSettings)
            // Additional: MutateCustomAudiencesAsync(string, IEnumerable<CustomAudienceOperation>, CancellationToken)
            // Create client
            CustomAudienceServiceClient customAudienceServiceClient = await CustomAudienceServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <CustomAudienceOperation> operations = new CustomAudienceOperation[]
            {
                new CustomAudienceOperation(),
            };
            // Make the request
            MutateCustomAudiencesResponse response = await customAudienceServiceClient.MutateCustomAudiencesAsync(customerId, operations);

            // End snippet
        }
Ejemplo n.º 7
0
        /// <summary>Snippet for MutateCustomAudiencesAsync</summary>
        public async Task MutateCustomAudiencesRequestObjectAsync()
        {
            // Snippet: MutateCustomAudiencesAsync(MutateCustomAudiencesRequest, CallSettings)
            // Additional: MutateCustomAudiencesAsync(MutateCustomAudiencesRequest, CancellationToken)
            // Create client
            CustomAudienceServiceClient customAudienceServiceClient = await CustomAudienceServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateCustomAudiencesRequest request = new MutateCustomAudiencesRequest
            {
                CustomerId = "",
                Operations =
                {
                    new CustomAudienceOperation(),
                },
                ValidateOnly = false,
            };
            // Make the request
            MutateCustomAudiencesResponse response = await customAudienceServiceClient.MutateCustomAudiencesAsync(request);

            // End snippet
        }