Пример #1
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The customer ID for which the call is made.</param>
        /// <param name="recommendationId">ID of the recommendation to dismiss.</param>
        public void Run(GoogleAdsClient client, long customerId, long recommendationId)
        {
            // Get the RecommendationServiceClient.
            RecommendationServiceClient service = client.GetService(
                Services.V3.RecommendationService);

            DismissRecommendationOperation operation = new DismissRecommendationOperation()
            {
                ResourceName = ResourceNames.Recommendation(customerId, recommendationId),
            };

            try
            {
                DismissRecommendationResponse response = service.DismissRecommendation(
                    customerId.ToString(), new DismissRecommendationOperation[] {
                    operation
                });
                foreach (DismissRecommendationResult result in response.Results)
                {
                    Console.WriteLine($"Dismissed recommendation 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;
            }
        }
Пример #2
0
 /// <summary>Snippet for DismissRecommendation</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void DismissRecommendation()
 {
     // Create client
     RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <DismissRecommendationRequest.Types.DismissRecommendationOperation> operations = new DismissRecommendationRequest.Types.DismissRecommendationOperation[]
     {
         new DismissRecommendationRequest.Types.DismissRecommendationOperation(),
     };
     // Make the request
     DismissRecommendationResponse response = recommendationServiceClient.DismissRecommendation(customerId, operations);
 }
 /// <summary>Snippet for DismissRecommendation</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void DismissRecommendationRequestObject()
 {
     // Create client
     RecommendationServiceClient recommendationServiceClient = RecommendationServiceClient.Create();
     // Initialize request argument(s)
     DismissRecommendationRequest request = new DismissRecommendationRequest
     {
         CustomerId     = "",
         PartialFailure = false,
         Operations     =
         {
             new DismissRecommendationRequest.Types.DismissRecommendationOperation(),
         },
     };
     // Make the request
     DismissRecommendationResponse response = recommendationServiceClient.DismissRecommendation(request);
 }