public async stt::Task MutateCampaignFeedsAsync() { moq::Mock <CampaignFeedService.CampaignFeedServiceClient> mockGrpcClient = new moq::Mock <CampaignFeedService.CampaignFeedServiceClient>(moq::MockBehavior.Strict); MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignFeedOperation(), }, }; MutateCampaignFeedsResponse expectedResponse = new MutateCampaignFeedsResponse { Results = { new MutateCampaignFeedResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaignFeedsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCampaignFeedsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CampaignFeedServiceClient client = new CampaignFeedServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignFeedsResponse responseCallSettings = await client.MutateCampaignFeedsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateCampaignFeedsResponse responseCancellationToken = await client.MutateCampaignFeedsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void MutateCampaignFeeds() { moq::Mock <CampaignFeedService.CampaignFeedServiceClient> mockGrpcClient = new moq::Mock <CampaignFeedService.CampaignFeedServiceClient>(moq::MockBehavior.Strict); MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignFeedOperation(), }, }; MutateCampaignFeedsResponse expectedResponse = new MutateCampaignFeedsResponse { Results = { new MutateCampaignFeedResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaignFeeds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignFeedServiceClient client = new CampaignFeedServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignFeedsResponse response = client.MutateCampaignFeeds(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Creates a campaign feed, which tells Google Ads which campaigns to use the provided /// data with. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <param name="campaignId">The campaign to receive the feed.</param> /// <param name="feed">The feed to connect to the campaign.</param> private void CreateCampaignFeed(GoogleAdsClient client, long customerId, long campaignId, Feed feed) { CampaignFeedServiceClient campaignFeedServiceClient = client.GetService(Services.V4.CampaignFeedService); // Fetch the Feed Item IDs and collapse them into a single comma-separated string. List <long> feedItemIds = feed.Attributes.Select(attr => attr.Id.Value).ToList(); string aggregatedFeedItemIds = string.Join(",", feedItemIds); CampaignFeed campaignFeed = new CampaignFeed() { Feed = feed.ResourceName, Campaign = ResourceNames.Campaign(customerId, campaignId), MatchingFunction = new MatchingFunction() { FunctionString = $"AND(IN(FEED_ITEM_ID,{{ {aggregatedFeedItemIds} }})," + "EQUALS(CONTEXT.DEVICE,'Mobile'))" } }; campaignFeed.PlaceholderTypes.Add(PlaceholderTypeEnum.Types.PlaceholderType.Sitelink); CampaignFeedOperation operation = new CampaignFeedOperation() { Create = campaignFeed }; MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds( customerId.ToString(), new[] { operation }); Console.WriteLine($"Created campaign feed '{response.Results.First().ResourceName}'"); }
public void MutateCampaignFeedsRequestObject() { moq::Mock <CampaignFeedService.CampaignFeedServiceClient> mockGrpcClient = new moq::Mock <CampaignFeedService.CampaignFeedServiceClient>(moq::MockBehavior.Strict); MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "customer_id3b3724cb", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = true, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateCampaignFeedsResponse expectedResponse = new MutateCampaignFeedsResponse { Results = { new MutateCampaignFeedResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateCampaignFeeds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignFeedServiceClient client = new CampaignFeedServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignFeedsResponse response = client.MutateCampaignFeeds(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateCampaignFeeds</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateCampaignFeeds() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <CampaignFeedOperation> operations = new CampaignFeedOperation[] { new CampaignFeedOperation(), }; // Make the request MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds(customerId, operations); }
public async Task MutateCampaignFeedsAsync3() { Mock <CampaignFeedService.CampaignFeedServiceClient> mockGrpcClient = new Mock <CampaignFeedService.CampaignFeedServiceClient>(MockBehavior.Strict); MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateCampaignFeedsResponse expectedResponse = new MutateCampaignFeedsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignFeedsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignFeedsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignFeedServiceClient client = new CampaignFeedServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignFeedsResponse response = await client.MutateCampaignFeedsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateCampaignFeeds3() { Mock <CampaignFeedService.CampaignFeedServiceClient> mockGrpcClient = new Mock <CampaignFeedService.CampaignFeedServiceClient>(MockBehavior.Strict); MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateCampaignFeedsResponse expectedResponse = new MutateCampaignFeedsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignFeeds(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CampaignFeedServiceClient client = new CampaignFeedServiceClientImpl(mockGrpcClient.Object, null); MutateCampaignFeedsResponse response = client.MutateCampaignFeeds(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateCampaignFeedsAsync</summary> public async Task MutateCampaignFeedsAsync() { // Snippet: MutateCampaignFeedsAsync(string, IEnumerable<CampaignFeedOperation>, CallSettings) // Additional: MutateCampaignFeedsAsync(string, IEnumerable<CampaignFeedOperation>, CancellationToken) // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <CampaignFeedOperation> operations = new CampaignFeedOperation[] { new CampaignFeedOperation(), }; // Make the request MutateCampaignFeedsResponse response = await campaignFeedServiceClient.MutateCampaignFeedsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateCampaignFeeds</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateCampaignFeedsRequestObject() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds(request); }
/// <summary>Snippet for MutateCampaignFeedsAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task MutateCampaignFeedsRequestObjectAsync() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateCampaignFeedsResponse response = await campaignFeedServiceClient.MutateCampaignFeedsAsync(request); }
/// <summary>Snippet for MutateCampaignFeeds</summary> public void MutateCampaignFeedsRequestObject() { // Snippet: MutateCampaignFeeds(MutateCampaignFeedsRequest, CallSettings) // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds(request); // End snippet }
/// <summary> /// Creates the campaign feed. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <param name="campaignId">The campaign ID for which the affiliate location extensions /// are added.</param> /// <param name="feedMapping">The affliate location extension feedmapping for /// <paramref name="feedResourceName"/></param> /// <param name="feedResourceName">The feed resource name.</param> /// <param name="chainId">The retail chain ID.</param> private static void CreateCampaignFeed(GoogleAdsClient client, long customerId, long campaignId, FeedMapping feedMapping, string feedResourceName, long chainId) { // Get the CampaignFeedService. CampaignFeedServiceClient campaignFeedService = client.GetService( Services.V5.CampaignFeedService); long attributeIdForChainId = GetAttributeIdForChainId(feedMapping); string feedId = FeedName.Parse(feedResourceName).FeedId; string matchingFunction = $"IN(FeedAttribute[{feedId}, {attributeIdForChainId}], {chainId})"; // Adds a CampaignFeed that associates the feed with this campaign for // the AFFILIATE_LOCATION placeholder type. CampaignFeed campaignFeed = new CampaignFeed() { Feed = feedResourceName, PlaceholderTypes = { PlaceholderType.AffiliateLocation }, MatchingFunction = new MatchingFunction() { FunctionString = matchingFunction }, Campaign = ResourceNames.Campaign(customerId, campaignId), }; CampaignFeedOperation operation = new CampaignFeedOperation() { Create = campaignFeed }; MutateCampaignFeedsResponse campaignFeedsResponse = campaignFeedService.MutateCampaignFeeds( customerId.ToString(), new[] { operation }); // Displays the result. string addedCampaignFeed = campaignFeedsResponse.Results[0].ResourceName; Console.WriteLine($"Campaign feed created with resource name: {addedCampaignFeed}."); return; }
/// <summary>Snippet for MutateCampaignFeedsAsync</summary> public async Task MutateCampaignFeedsRequestObjectAsync() { // Snippet: MutateCampaignFeedsAsync(MutateCampaignFeedsRequest, CallSettings) // Additional: MutateCampaignFeedsAsync(MutateCampaignFeedsRequest, CancellationToken) // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateCampaignFeedsResponse response = await campaignFeedServiceClient.MutateCampaignFeedsAsync(request); // End snippet }
public async Task MutateCampaignFeedsAsync() { Mock <CampaignFeedService.CampaignFeedServiceClient> mockGrpcClient = new Mock <CampaignFeedService.CampaignFeedServiceClient>(MockBehavior.Strict); MutateCampaignFeedsRequest expectedRequest = new MutateCampaignFeedsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateCampaignFeedsResponse expectedResponse = new MutateCampaignFeedsResponse(); mockGrpcClient.Setup(x => x.MutateCampaignFeedsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignFeedsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignFeedServiceClient client = new CampaignFeedServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <CampaignFeedOperation> operations = new List <CampaignFeedOperation>(); bool partialFailure = true; bool validateOnly = false; MutateCampaignFeedsResponse response = await client.MutateCampaignFeedsAsync(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }