Esempio n. 1
0
        public void MutateBiddingDataExclusions()
        {
            moq::Mock <BiddingDataExclusionService.BiddingDataExclusionServiceClient> mockGrpcClient = new moq::Mock <BiddingDataExclusionService.BiddingDataExclusionServiceClient>(moq::MockBehavior.Strict);
            MutateBiddingDataExclusionsRequest request = new MutateBiddingDataExclusionsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new BiddingDataExclusionOperation(),
                },
            };
            MutateBiddingDataExclusionsResponse expectedResponse = new MutateBiddingDataExclusionsResponse
            {
                Results =
                {
                    new MutateBiddingDataExclusionsResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateBiddingDataExclusions(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            BiddingDataExclusionServiceClient   client   = new BiddingDataExclusionServiceClientImpl(mockGrpcClient.Object, null);
            MutateBiddingDataExclusionsResponse response = client.MutateBiddingDataExclusions(request.CustomerId, request.Operations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public async stt::Task MutateBiddingDataExclusionsAsync()
        {
            moq::Mock <BiddingDataExclusionService.BiddingDataExclusionServiceClient> mockGrpcClient = new moq::Mock <BiddingDataExclusionService.BiddingDataExclusionServiceClient>(moq::MockBehavior.Strict);
            MutateBiddingDataExclusionsRequest request = new MutateBiddingDataExclusionsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new BiddingDataExclusionOperation(),
                },
            };
            MutateBiddingDataExclusionsResponse expectedResponse = new MutateBiddingDataExclusionsResponse
            {
                Results =
                {
                    new MutateBiddingDataExclusionsResult(),
                },
                PartialFailureError = new gr::Status(),
            };

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

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

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio 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 call is made.</param>
        /// <param name="startDateTime">The start time of the data exclusion (in
        /// yyyy-MM-dd HH:mm:ss format) in the account's timezone.</param>
        /// <param name="endDateTime">The end time of the data exclusion (in
        /// yyyy-MM-dd HH:mm:ss format) in the account's timezone.</param>
        public void Run(GoogleAdsClient client, long customerId, string startDateTime,
                        string endDateTime)
        {
            // Get the BiddingDataExclusionServiceClient.
            BiddingDataExclusionServiceClient biddingDataExclusionService =
                client.GetService(Services.V10.BiddingDataExclusionService);

            // [START add_bidding_data_exclusion]
            BiddingDataExclusion dataExclusion = new BiddingDataExclusion()
            {
                // A unique name is required for every data exclusion.
                Name = "Data exclusion #" + ExampleUtilities.GetRandomString(),
                // The CHANNEL scope applies the data exclusion to all campaigns of specific
                // advertising channel types. In this example, the the exclusion will only apply to
                // Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific
                // campaigns.
                Scope = SeasonalityEventScope.Channel,
                AdvertisingChannelTypes = { AdvertisingChannelType.Search },
                // The date range should be less than 14 days.
                StartDateTime = startDateTime,
                EndDateTime   = endDateTime,
            };
            BiddingDataExclusionOperation operation = new BiddingDataExclusionOperation()
            {
                Create = dataExclusion
            };

            try
            {
                MutateBiddingDataExclusionsResponse response =
                    biddingDataExclusionService.MutateBiddingDataExclusions(
                        customerId.ToString(), new[] { operation });
                Console.WriteLine($"Added data exclusion with resource name: " +
                                  $"{response.Results[0].ResourceName}");
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
            // [END add_bidding_data_exclusion]
        }