public async stt::Task MutateFeedItemSetLinksAsync() { moq::Mock <FeedItemSetLinkService.FeedItemSetLinkServiceClient> mockGrpcClient = new moq::Mock <FeedItemSetLinkService.FeedItemSetLinkServiceClient>(moq::MockBehavior.Strict); MutateFeedItemSetLinksRequest request = new MutateFeedItemSetLinksRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedItemSetLinkOperation(), }, }; MutateFeedItemSetLinksResponse expectedResponse = new MutateFeedItemSetLinksResponse { Results = { new MutateFeedItemSetLinkResult(), }, }; mockGrpcClient.Setup(x => x.MutateFeedItemSetLinksAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateFeedItemSetLinksResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FeedItemSetLinkServiceClient client = new FeedItemSetLinkServiceClientImpl(mockGrpcClient.Object, null); MutateFeedItemSetLinksResponse responseCallSettings = await client.MutateFeedItemSetLinksAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateFeedItemSetLinksResponse responseCancellationToken = await client.MutateFeedItemSetLinksAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void MutateFeedItemSetLinks() { moq::Mock <FeedItemSetLinkService.FeedItemSetLinkServiceClient> mockGrpcClient = new moq::Mock <FeedItemSetLinkService.FeedItemSetLinkServiceClient>(moq::MockBehavior.Strict); MutateFeedItemSetLinksRequest request = new MutateFeedItemSetLinksRequest { CustomerId = "customer_id3b3724cb", Operations = { new FeedItemSetLinkOperation(), }, }; MutateFeedItemSetLinksResponse expectedResponse = new MutateFeedItemSetLinksResponse { Results = { new MutateFeedItemSetLinkResult(), }, }; mockGrpcClient.Setup(x => x.MutateFeedItemSetLinks(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FeedItemSetLinkServiceClient client = new FeedItemSetLinkServiceClientImpl(mockGrpcClient.Object, null); MutateFeedItemSetLinksResponse response = client.MutateFeedItemSetLinks(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateFeedItemSetLinks</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedItemSetLinks() { // Create client FeedItemSetLinkServiceClient feedItemSetLinkServiceClient = FeedItemSetLinkServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <FeedItemSetLinkOperation> operations = new FeedItemSetLinkOperation[] { new FeedItemSetLinkOperation(), }; // Make the request MutateFeedItemSetLinksResponse response = feedItemSetLinkServiceClient.MutateFeedItemSetLinks(customerId, operations); }
/// <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">ID of the feed associated with the feed item set.</param> /// <param name="feedItemSetId">ID of the feed item set.</param> /// <param name="feedItemId">ID of the feed item to link to the set.</param> public void Run(GoogleAdsClient client, long customerId, long feedId, long feedItemSetId, long feedItemId) { // Get the FeedItemSetLinkService. FeedItemSetLinkServiceClient feedItemSetLinkService = client.GetService( Services.V10.FeedItemSetLinkService); // Creates a new feed item set link that binds the specified feed item set and feed // item. string feedItemSetResourceName = ResourceNames.FeedItemSet(customerId, feedId, feedItemSetId); string feedItemResourceName = ResourceNames.FeedItem(customerId, feedId, feedItemId); FeedItemSetLink feedItemSetLink = new FeedItemSetLink() { FeedItemSet = feedItemSetResourceName, FeedItem = feedItemResourceName }; // Constructs a feed item set link operation. FeedItemSetLinkOperation operation = new FeedItemSetLinkOperation() { Create = feedItemSetLink }; try { // Issues a mutate request to add the feed item set link on the server. MutateFeedItemSetLinksResponse response = feedItemSetLinkService.MutateFeedItemSetLinks(customerId.ToString(), new[] { operation }); // Prints some information about the created feed item set link. foreach (MutateFeedItemSetLinkResult result in response.Results) { Console.WriteLine($"Created a feed item set link with resource name " + $"'{result.ResourceName}' that links feed item set " + $"'{feedItemSetResourceName}' to feed item '{feedItemResourceName}'."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary>Snippet for MutateFeedItemSetLinksAsync</summary> public async Task MutateFeedItemSetLinksAsync() { // Snippet: MutateFeedItemSetLinksAsync(string, IEnumerable<FeedItemSetLinkOperation>, CallSettings) // Additional: MutateFeedItemSetLinksAsync(string, IEnumerable<FeedItemSetLinkOperation>, CancellationToken) // Create client FeedItemSetLinkServiceClient feedItemSetLinkServiceClient = await FeedItemSetLinkServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <FeedItemSetLinkOperation> operations = new FeedItemSetLinkOperation[] { new FeedItemSetLinkOperation(), }; // Make the request MutateFeedItemSetLinksResponse response = await feedItemSetLinkServiceClient.MutateFeedItemSetLinksAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateFeedItemSetLinks</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedItemSetLinksRequestObject() { // Create client FeedItemSetLinkServiceClient feedItemSetLinkServiceClient = FeedItemSetLinkServiceClient.Create(); // Initialize request argument(s) MutateFeedItemSetLinksRequest request = new MutateFeedItemSetLinksRequest { CustomerId = "", Operations = { new FeedItemSetLinkOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateFeedItemSetLinksResponse response = feedItemSetLinkServiceClient.MutateFeedItemSetLinks(request); }
/// <summary>Snippet for MutateFeedItemSetLinksAsync</summary> public async Task MutateFeedItemSetLinksRequestObjectAsync() { // Snippet: MutateFeedItemSetLinksAsync(MutateFeedItemSetLinksRequest, CallSettings) // Additional: MutateFeedItemSetLinksAsync(MutateFeedItemSetLinksRequest, CancellationToken) // Create client FeedItemSetLinkServiceClient feedItemSetLinkServiceClient = await FeedItemSetLinkServiceClient.CreateAsync(); // Initialize request argument(s) MutateFeedItemSetLinksRequest request = new MutateFeedItemSetLinksRequest { CustomerId = "", Operations = { new FeedItemSetLinkOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateFeedItemSetLinksResponse response = await feedItemSetLinkServiceClient.MutateFeedItemSetLinksAsync(request); // End snippet }