public async stt::Task MutateFeedItemSetsAsync() { moq::Mock <FeedItemSetService.FeedItemSetServiceClient> mockGrpcClient = new moq::Mock <FeedItemSetService.FeedItemSetServiceClient>(moq::MockBehavior.Strict); MutateFeedItemSetsRequest request = new MutateFeedItemSetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedItemSetOperation(), }, }; MutateFeedItemSetsResponse expectedResponse = new MutateFeedItemSetsResponse { Results = { new MutateFeedItemSetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateFeedItemSetsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateFeedItemSetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FeedItemSetServiceClient client = new FeedItemSetServiceClientImpl(mockGrpcClient.Object, null); MutateFeedItemSetsResponse responseCallSettings = await client.MutateFeedItemSetsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateFeedItemSetsResponse responseCancellationToken = await client.MutateFeedItemSetsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void MutateFeedItemSets() { moq::Mock <FeedItemSetService.FeedItemSetServiceClient> mockGrpcClient = new moq::Mock <FeedItemSetService.FeedItemSetServiceClient>(moq::MockBehavior.Strict); MutateFeedItemSetsRequest request = new MutateFeedItemSetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedItemSetOperation(), }, }; MutateFeedItemSetsResponse expectedResponse = new MutateFeedItemSetsResponse { Results = { new MutateFeedItemSetResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateFeedItemSets(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FeedItemSetServiceClient client = new FeedItemSetServiceClientImpl(mockGrpcClient.Object, null); MutateFeedItemSetsResponse response = client.MutateFeedItemSets(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateFeedItemSets</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedItemSets() { // Create client FeedItemSetServiceClient feedItemSetServiceClient = FeedItemSetServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <FeedItemSetOperation> operations = new FeedItemSetOperation[] { new FeedItemSetOperation(), }; // Make the request MutateFeedItemSetsResponse response = feedItemSetServiceClient.MutateFeedItemSets(customerId, operations); }
/// <summary>Snippet for MutateFeedItemSetsAsync</summary> public async Task MutateFeedItemSetsAsync() { // Snippet: MutateFeedItemSetsAsync(string, IEnumerable<FeedItemSetOperation>, CallSettings) // Additional: MutateFeedItemSetsAsync(string, IEnumerable<FeedItemSetOperation>, CancellationToken) // Create client FeedItemSetServiceClient feedItemSetServiceClient = await FeedItemSetServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <FeedItemSetOperation> operations = new FeedItemSetOperation[] { new FeedItemSetOperation(), }; // Make the request MutateFeedItemSetsResponse response = await feedItemSetServiceClient.MutateFeedItemSetsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateFeedItemSets</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedItemSetsRequestObject() { // Create client FeedItemSetServiceClient feedItemSetServiceClient = FeedItemSetServiceClient.Create(); // Initialize request argument(s) MutateFeedItemSetsRequest request = new MutateFeedItemSetsRequest { CustomerId = "", Operations = { new FeedItemSetOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateFeedItemSetsResponse response = feedItemSetServiceClient.MutateFeedItemSets(request); }
/// <summary>Snippet for MutateFeedItemSetsAsync</summary> public async Task MutateFeedItemSetsRequestObjectAsync() { // Snippet: MutateFeedItemSetsAsync(MutateFeedItemSetsRequest, CallSettings) // Additional: MutateFeedItemSetsAsync(MutateFeedItemSetsRequest, CancellationToken) // Create client FeedItemSetServiceClient feedItemSetServiceClient = await FeedItemSetServiceClient.CreateAsync(); // Initialize request argument(s) MutateFeedItemSetsRequest request = new MutateFeedItemSetsRequest { CustomerId = "", Operations = { new FeedItemSetOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateFeedItemSetsResponse response = await feedItemSetServiceClient.MutateFeedItemSetsAsync(request); // End snippet }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads API client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="feedId">The Feed ID for creating the feed item set.</param> public void Run(GoogleAdsClient client, long customerId, long feedId) { // Get the FeedItemSetService. FeedItemSetServiceClient feedItemService = client.GetService( Services.V6.FeedItemSetService); FeedItemSet feedItemSet = new FeedItemSet() { Feed = ResourceNames.Feed(customerId, feedId), DisplayName = "Feed Item Set #" + ExampleUtilities.GetRandomString(), }; // A feed item set can be created as a dynamic set by setting an optional filter // field below. If your feed is a location extension, uncomment the code that calls // DynamicLocationSetFilter. If instead your feed is an affiliate extension, // uncomment the code that sets the DynamicAffiliateLocationSetFilter instead. // 1) Location extension. //feedItemSet.DynamicLocationSetFilter = new DynamicLocationSetFilter() //{ // // Dynamic location sets support filtering locations based on business name // // and/or labels. If both are specified, the feed item set will only include // // locations that satisfy both types of filters. // BusinessNameFilter = new BusinessNameFilter() // { // BusinessName = "INSERT_YOUR_BUSINESS_NAME_HERE", // FilterType = FeedItemSetStringFilterType.Exact, // }, // // Adds a filter by feed item label resource name. If multiple labels are // // specified, the feed item set will only include feed items with all of the // // specified labels. // Labels = { "INSERT_BUSINESS_LABEL_HERE" } //}; // 2) Affiliate extension. //feedItemSet.DynamicAffiliateLocationSetFilter = new DynamicAffiliateLocationSetFilter() //{ // ChainIds = { long.Parse("INSERT_CHAIN_ID_HERE") } //}; // Constructs an operation that will create a new feed item set. FeedItemSetOperation operation = new FeedItemSetOperation() { Create = feedItemSet }; try { // Issues a mutate request to add the feed item set on the server. MutateFeedItemSetsResponse response = feedItemService.MutateFeedItemSets(customerId.ToString(), new[] { operation }); // Prints the resource names of the added feed item sets. foreach (MutateFeedItemSetResult addedFeedItemSet in response.Results) { Console.WriteLine("Created a feed item set with resource name " + $"'{addedFeedItemSet.ResourceName}'"); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }