Ejemplo n.º 1
0
        public void MutateExtensionFeedItems()
        {
            moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(moq::MockBehavior.Strict);
            MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new ExtensionFeedItemOperation(),
                },
            };
            MutateExtensionFeedItemsResponse expectedResponse = new MutateExtensionFeedItemsResponse
            {
                Results =
                {
                    new MutateExtensionFeedItemResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateExtensionFeedItems(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ExtensionFeedItemServiceClient   client   = new ExtensionFeedItemServiceClientImpl(mockGrpcClient.Object, null);
            MutateExtensionFeedItemsResponse response = client.MutateExtensionFeedItems(request.CustomerId, request.Operations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void MutateExtensionFeedItemsRequestObject()
        {
            moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(moq::MockBehavior.Strict);
            MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new ExtensionFeedItemOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = true,
                ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly,
            };
            MutateExtensionFeedItemsResponse expectedResponse = new MutateExtensionFeedItemsResponse
            {
                Results =
                {
                    new MutateExtensionFeedItemResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateExtensionFeedItems(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ExtensionFeedItemServiceClient   client   = new ExtensionFeedItemServiceClientImpl(mockGrpcClient.Object, null);
            MutateExtensionFeedItemsResponse response = client.MutateExtensionFeedItems(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 3
0
        public async stt::Task MutateExtensionFeedItemsAsync()
        {
            moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(moq::MockBehavior.Strict);
            MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new ExtensionFeedItemOperation(),
                },
            };
            MutateExtensionFeedItemsResponse expectedResponse = new MutateExtensionFeedItemsResponse
            {
                Results =
                {
                    new MutateExtensionFeedItemResult(),
                },
                PartialFailureError = new gr::Status(),
            };

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

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

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 4
0
 /// <summary>Snippet for MutateExtensionFeedItems</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateExtensionFeedItems()
 {
     // Create client
     ExtensionFeedItemServiceClient extensionFeedItemServiceClient = ExtensionFeedItemServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <ExtensionFeedItemOperation> operations = new ExtensionFeedItemOperation[]
     {
         new ExtensionFeedItemOperation(),
     };
     // Make the request
     MutateExtensionFeedItemsResponse response = extensionFeedItemServiceClient.MutateExtensionFeedItems(customerId, operations);
 }
Ejemplo n.º 5
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="feedItemId">The feed item ID.</param>
        /// <param name="geoTargetConstantId">Geo target constant ID to add to the extension
        ///     feed item. Reverts to the United States (2840) if no value passed.</param>
        // [START AddGeoTarget]
        public void Run(GoogleAdsClient client, long customerId, long feedItemId,
                        long?geoTargetConstantId)
        {
            // Get the ExtensionFeedItemServiceClient.
            ExtensionFeedItemServiceClient extensionFeedItemServiceClient =
                client.GetService(Services.V6.ExtensionFeedItemService);

            // Apply the default geo target constant ID (USA) if none was passed to the function.
            if (!geoTargetConstantId.HasValue)
            {
                geoTargetConstantId = 2840L;
            }

            // Creates an extension feed item using the specified feed item ID and geo target
            // constant ID for targeting.
            ExtensionFeedItem extensionFeedItem = new ExtensionFeedItem()
            {
                ResourceName = ResourceNames.ExtensionFeedItem(customerId, feedItemId),
                TargetedGeoTargetConstant = ResourceNames.GeoTargetConstant(geoTargetConstantId.Value)
            };

            // Constructs an operation that will update the extension feed item, using the
            // FieldMasks utility to derive the update mask. This mask tells the Google Ads API
            // which attributes of the extension feed item you want to change.
            ExtensionFeedItemOperation operation = new ExtensionFeedItemOperation()
            {
                Update     = extensionFeedItem,
                UpdateMask = FieldMasks.AllSetFieldsOf(extensionFeedItem)
            };

            try
            {
                // Issues a mutate request to update the extension feed item.
                MutateExtensionFeedItemsResponse response =
                    extensionFeedItemServiceClient.MutateExtensionFeedItems(customerId.ToString(),
                                                                            new[] { operation });

                // Prints the resource name of the updated extension feed item.
                Console.WriteLine("Updated extension feed item with resource name " +
                                  $"{response.Results.First().ResourceName}.");
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
Ejemplo n.º 6
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="feedItemId">The feed item ID to update.</param>
        /// <param name="sitelinkText">The new sitelink text.</param>
        // [START UpdateSitelink]
        public void Run(GoogleAdsClient client, long customerId, long feedItemId,
                        string sitelinkText)
        {
            // Get the ExtensionFeedItemService.
            ExtensionFeedItemServiceClient extensionFeedItemService =
                client.GetService(Services.V6.ExtensionFeedItemService);

            // Create an extension feed item using the specified feed item ID and sitelink text.
            ExtensionFeedItem extensionFeedItem = new ExtensionFeedItem
            {
                ResourceName     = ResourceNames.ExtensionFeedItem(customerId, feedItemId),
                SitelinkFeedItem = new SitelinkFeedItem
                {
                    LinkText = sitelinkText
                }
            };

            // Construct an operation that will update the extension feed item using the FieldMasks
            // utilities to derive the update mask. This mask tells the Google Ads API which
            // attributes of the extension feed item you want to change.
            ExtensionFeedItemOperation extensionFeedItemOperation = new ExtensionFeedItemOperation
            {
                Update     = extensionFeedItem,
                UpdateMask = FieldMasks.AllSetFieldsOf(extensionFeedItem)
            };

            try
            {
                // Issue a mutate request to update the extension feed item.
                MutateExtensionFeedItemsResponse response =
                    extensionFeedItemService.MutateExtensionFeedItems(
                        customerId.ToString(), new[] { extensionFeedItemOperation });

                // Print the resource name of the updated extension feed item.
                Console.WriteLine("Updated extension feed item with resource name " +
                                  $"'{response.Results.First().ResourceName}'.");
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
Ejemplo n.º 7
0
        public async Task MutateExtensionFeedItemsAsync3()
        {
            Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(MockBehavior.Strict);
            MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateExtensionFeedItemsResponse expectedResponse = new MutateExtensionFeedItemsResponse();

            mockGrpcClient.Setup(x => x.MutateExtensionFeedItemsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateExtensionFeedItemsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ExtensionFeedItemServiceClient   client   = new ExtensionFeedItemServiceClientImpl(mockGrpcClient.Object, null);
            MutateExtensionFeedItemsResponse response = await client.MutateExtensionFeedItemsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 8
0
        public void MutateExtensionFeedItems3()
        {
            Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(MockBehavior.Strict);
            MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateExtensionFeedItemsResponse expectedResponse = new MutateExtensionFeedItemsResponse();

            mockGrpcClient.Setup(x => x.MutateExtensionFeedItems(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ExtensionFeedItemServiceClient   client   = new ExtensionFeedItemServiceClientImpl(mockGrpcClient.Object, null);
            MutateExtensionFeedItemsResponse response = client.MutateExtensionFeedItems(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for MutateExtensionFeedItems</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateExtensionFeedItemsRequestObject()
 {
     // Create client
     ExtensionFeedItemServiceClient extensionFeedItemServiceClient = ExtensionFeedItemServiceClient.Create();
     // Initialize request argument(s)
     MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
     {
         CustomerId = "",
         Operations =
         {
             new ExtensionFeedItemOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateExtensionFeedItemsResponse response = extensionFeedItemServiceClient.MutateExtensionFeedItems(request);
 }
        /// <summary>Snippet for MutateExtensionFeedItemsAsync</summary>
        public async Task MutateExtensionFeedItemsAsync()
        {
            // Snippet: MutateExtensionFeedItemsAsync(string, IEnumerable<ExtensionFeedItemOperation>, CallSettings)
            // Additional: MutateExtensionFeedItemsAsync(string, IEnumerable<ExtensionFeedItemOperation>, CancellationToken)
            // Create client
            ExtensionFeedItemServiceClient extensionFeedItemServiceClient = await ExtensionFeedItemServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <ExtensionFeedItemOperation> operations = new ExtensionFeedItemOperation[]
            {
                new ExtensionFeedItemOperation(),
            };
            // Make the request
            MutateExtensionFeedItemsResponse response = await extensionFeedItemServiceClient.MutateExtensionFeedItemsAsync(customerId, operations);

            // End snippet
        }
        /// <summary>Snippet for MutateExtensionFeedItemsAsync</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 MutateExtensionFeedItemsRequestObjectAsync()
        {
            // Create client
            ExtensionFeedItemServiceClient extensionFeedItemServiceClient = await ExtensionFeedItemServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new ExtensionFeedItemOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = false,
                ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
            };
            // Make the request
            MutateExtensionFeedItemsResponse response = await extensionFeedItemServiceClient.MutateExtensionFeedItemsAsync(request);
        }
 /// <summary>Snippet for MutateExtensionFeedItems</summary>
 public void MutateExtensionFeedItemsRequestObject()
 {
     // Snippet: MutateExtensionFeedItems(MutateExtensionFeedItemsRequest, CallSettings)
     // Create client
     ExtensionFeedItemServiceClient extensionFeedItemServiceClient = ExtensionFeedItemServiceClient.Create();
     // Initialize request argument(s)
     MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
     {
         CustomerId = "",
         Operations =
         {
             new ExtensionFeedItemOperation(),
         },
         PartialFailure      = false,
         ValidateOnly        = false,
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateExtensionFeedItemsResponse response = extensionFeedItemServiceClient.MutateExtensionFeedItems(request);
     // End snippet
 }
Ejemplo n.º 13
0
        public void MutateExtensionFeedItems()
        {
            Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(MockBehavior.Strict);
            MutateExtensionFeedItemsRequest expectedRequest = new MutateExtensionFeedItemsRequest
            {
                CustomerId   = "customerId-1772061412",
                Operations   = { },
                ValidateOnly = false,
            };
            MutateExtensionFeedItemsResponse expectedResponse = new MutateExtensionFeedItemsResponse();

            mockGrpcClient.Setup(x => x.MutateExtensionFeedItems(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ExtensionFeedItemServiceClient client = new ExtensionFeedItemServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            IEnumerable <ExtensionFeedItemOperation> operations = new List <ExtensionFeedItemOperation>();
            bool validateOnly = false;
            MutateExtensionFeedItemsResponse response = client.MutateExtensionFeedItems(customerId, operations, validateOnly);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 14
0
        /// <summary>Snippet for MutateExtensionFeedItemsAsync</summary>
        public async Task MutateExtensionFeedItemsRequestObjectAsync()
        {
            // Snippet: MutateExtensionFeedItemsAsync(MutateExtensionFeedItemsRequest, CallSettings)
            // Additional: MutateExtensionFeedItemsAsync(MutateExtensionFeedItemsRequest, CancellationToken)
            // Create client
            ExtensionFeedItemServiceClient extensionFeedItemServiceClient = await ExtensionFeedItemServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateExtensionFeedItemsRequest request = new MutateExtensionFeedItemsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new ExtensionFeedItemOperation(),
                },
                PartialFailure = false,
                ValidateOnly   = false,
            };
            // Make the request
            MutateExtensionFeedItemsResponse response = await extensionFeedItemServiceClient.MutateExtensionFeedItemsAsync(request);

            // End snippet
        }
        /// <summary>
        /// Creates an image extension.
        /// </summary>
        /// <param name="client">The Google Ads API client.</param>
        /// <param name="customerId">The client customer ID.</param>
        /// <param name="imageAssetId">The ID of the image asset to be used for creating image
        /// extension.</param>
        /// <returns>Resource name of the newly created image extension.</returns>
        private static string CreateImageExtension(GoogleAdsClient client, long customerId,
                                                   long imageAssetId)
        {
            // Get the ExtensionFeedItemServiceClient.
            ExtensionFeedItemServiceClient extensionFeedItemService =
                client.GetService(Services.V10.ExtensionFeedItemService);

            // Creates the image feed item using the provided image.
            ImageFeedItem imageFeedItem = new ImageFeedItem()
            {
                ImageAsset = ResourceNames.Asset(customerId, imageAssetId)
            };

            // Creates an ExtensionFeedItem from the ImageFeedItem.
            ExtensionFeedItem extensionFeedItem = new ExtensionFeedItem()
            {
                ImageFeedItem = imageFeedItem
            };

            ExtensionFeedItemOperation operation = new ExtensionFeedItemOperation()
            {
                Create = extensionFeedItem
            };

            // Adds the ExtensionFeedItem.
            MutateExtensionFeedItemsResponse response =
                extensionFeedItemService.MutateExtensionFeedItems(customerId.ToString(),
                                                                  new[] { operation });

            // Displays the result.
            string resourceName = response.Results.First().ResourceName;

            Console.WriteLine($"Created an image extension with resource name '{resourceName}'.");

            return(resourceName);
        }
Ejemplo n.º 16
0
        public async Task MutateExtensionFeedItemsAsync()
        {
            Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(MockBehavior.Strict);
            MutateExtensionFeedItemsRequest expectedRequest = new MutateExtensionFeedItemsRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateExtensionFeedItemsResponse expectedResponse = new MutateExtensionFeedItemsResponse();

            mockGrpcClient.Setup(x => x.MutateExtensionFeedItemsAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateExtensionFeedItemsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ExtensionFeedItemServiceClient client = new ExtensionFeedItemServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            IEnumerable <ExtensionFeedItemOperation> operations = new List <ExtensionFeedItemOperation>();
            bool partialFailure = true;
            bool validateOnly   = false;
            MutateExtensionFeedItemsResponse response = await client.MutateExtensionFeedItemsAsync(customerId, operations, partialFailure, validateOnly);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates an extension feed item for price extension.
        /// </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">ID of the campaign to target.</param>
        /// <returns>the resource name of the newly created extension feed item.</returns>
        private string CreateExtensionFeedItem(GoogleAdsClient client, long customerId,
                                               long campaignId)
        {
            // Get the ExtensionFeedItemServiceClient.
            ExtensionFeedItemServiceClient extensionFeedItemService =
                client.GetService(Services.V3.ExtensionFeedItemService);

            // Creates the price extension feed item.
            PriceFeedItem priceFeedItem = new PriceFeedItem()
            {
                Type = PriceExtensionType.Services,
                // Optional: sets a qualifier text to show with the price extension.
                PriceQualifier      = PriceExtensionPriceQualifier.From,
                TrackingUrlTemplate = "http://tracker.example.com/?u={lpurl}",
                LanguageCode        = "en",
                // To create a price extension, at least three price offerings are needed.
                PriceOfferings =
                {
                    CreatePriceOffer(
                        "Scrubs",
                        "Body Scrub, Salt Scrub",
                        60000000, // 60 USD
                        "USD",
                        PriceExtensionPriceUnit.PerHour,
                        "http://www.example.com/scrubs",
                        "http://m.example.com/scrubs"),
                    CreatePriceOffer(
                        "Hair Cuts",
                        "Once a month",
                        75000000, // 75 USD
                        "USD",
                        PriceExtensionPriceUnit.PerMonth,
                        "http://www.example.com/haircuts",
                        "http://m.example.com/haircuts"),
                    CreatePriceOffer(
                        "Skin Care Package",
                        "Four times a month",
                        250000000, // 250 USD
                        "USD",
                        PriceExtensionPriceUnit.PerMonth,
                        "http://www.example.com/skincarepackage",
                        null)
                }
            };

            // Creates an extension feed item from the price feed item.
            ExtensionFeedItem extensionFeedItem = new ExtensionFeedItem()
            {
                ExtensionType    = ExtensionType.Price,
                PriceFeedItem    = priceFeedItem,
                TargetedCampaign = ResourceNames.Campaign(customerId, campaignId),
                AdSchedules      =
                {
                    CreateAdScheduleInfo(DayOfWeekEnum.Types.DayOfWeek.Sunday,      10,
                                         MinuteOfHour.Zero,                         18, MinuteOfHour.Zero),
                    CreateAdScheduleInfo(DayOfWeekEnum.Types.DayOfWeek.Saturday,    10,
                                         MinuteOfHour.Zero,                         22, MinuteOfHour.Zero)
                }
            };

            // Creates an operation to add the feed item.
            ExtensionFeedItemOperation operation = new ExtensionFeedItemOperation()
            {
                Create = extensionFeedItem
            };

            // Issues a mutate request to add the extension feed item and prints its information.
            MutateExtensionFeedItemsResponse response =
                extensionFeedItemService.MutateExtensionFeedItems(customerId.ToString(),
                                                                  new[] { operation });
            string resourceName = response.Results[0].ResourceName;

            Console.WriteLine($"Created extension feed item with resource name: {resourceName}.");
            return(resourceName);
        }
Ejemplo n.º 18
0
        // [END AddSitelinks]

        /// <summary>
        /// Creates a list of ExtensionFeedItems.
        /// </summary>
        ///<param name="client">The Google Ads API client.</param>
        ///<param name="customerId">The client customer ID.</param>
        ///<param name="campaignResourceName">The resource name of the campaign to target.</param>
        // [START AddSitelinks_1]
        private static List <string> CreateExtensionFeedItems(GoogleAdsClient client,
                                                              long customerId, string campaignResourceName)
        {
            // Get the ExtensionFeedItemServiceClient.
            ExtensionFeedItemServiceClient extensionFeedItemService =
                client.GetService(Services.V6.ExtensionFeedItemService);

            SitelinkFeedItem sitelinkFeedItem1 = CreateSitelinkFeedItem(
                "Store Hours", "http://www.example.com/storehours");

            // Creates an ExtensionFeedItem from the SitelinkFeedItem.
            ExtensionFeedItem extensionFeedItem1 = new ExtensionFeedItem()
            {
                ExtensionType    = ExtensionType.Sitelink,
                SitelinkFeedItem = sitelinkFeedItem1,
                TargetedCampaign = campaignResourceName
            };

            List <ExtensionFeedItemOperation> operations = new List <ExtensionFeedItemOperation>();

            // Creates an ExtensionFeedItemOperation and adds it to the operations List.
            operations.Add(new ExtensionFeedItemOperation()
            {
                Create = extensionFeedItem1
            });

            SitelinkFeedItem sitelinkFeedItem2 = CreateSitelinkFeedItem(
                "Thanksgiving Specials", "http://www.example.com/thanksgiving");

            DateTime startTime = new DateTime(DateTime.Now.Year, 11, 20, 0, 0, 0);

            if (startTime < DateTime.Now)
            {
                // Move the startTime to next year if the current date is past November 20th.
                startTime = startTime.AddYears(1);
            }

            // Converts to a string in the required format.
            string startTimeString = startTime.ToString("yyyy-MM-dd hh:mm:ss");

            // Use the same year as startTime when creating endTime.
            DateTime endTime = new DateTime(startTime.Year, 11, 27, 23, 59, 59);

            string unitedStates = ResourceNames.GeoTargetConstant(2840);

            ExtensionFeedItem extensionFeedItem2 = new ExtensionFeedItem()
            {
                ExtensionType    = ExtensionType.Sitelink,
                SitelinkFeedItem = sitelinkFeedItem2,
                TargetedCampaign = campaignResourceName,

                // StartDateTime should be formatted in "yyyy-MM-dd hh:mm:ss" format.
                StartDateTime = startTime.ToString("yyyy-MM-dd hh:mm:ss"),

                // EndDateTime should be formatted in "yyyy-MM-dd hh:mm:ss" format.
                EndDateTime = endTime.ToString("yyyy-MM-dd hh:mm:ss"),

                // Targets this sitelink for United States only.
                // A list of country codes can be referenced here:
                // https://developers.google.com/adwords/api/docs/appendix/geotargeting
                TargetedGeoTargetConstant = ResourceNames.GeoTargetConstant(2840)
            };

            operations.Add(new ExtensionFeedItemOperation()
            {
                Create = extensionFeedItem2
            });

            SitelinkFeedItem sitelinkFeedItem3 = CreateSitelinkFeedItem(
                "Wifi available", "http://www.example.com/mobile/wifi");

            ExtensionFeedItem extensionFeedItem3 = new ExtensionFeedItem()
            {
                ExtensionType    = ExtensionType.Sitelink,
                SitelinkFeedItem = sitelinkFeedItem3,
                TargetedCampaign = campaignResourceName,
                Device           = FeedItemTargetDevice.Mobile,
                TargetedKeyword  = new KeywordInfo()
                {
                    Text      = "free wifi",
                    MatchType = KeywordMatchType.Broad
                }
            };

            operations.Add(new ExtensionFeedItemOperation()
            {
                Create = extensionFeedItem3
            });

            SitelinkFeedItem sitelinkFeedItem4 = CreateSitelinkFeedItem(
                "Happy hours", "http://www.example.com/happyhours");

            ExtensionFeedItem extensionFeedItem4 = new ExtensionFeedItem()
            {
                ExtensionType    = ExtensionType.Sitelink,
                SitelinkFeedItem = sitelinkFeedItem4,
                TargetedCampaign = campaignResourceName,
                AdSchedules      =
                {
                    CreateAdScheduleInfo(DayOfWeekEnum.Types.DayOfWeek.Monday,      18,
                                         MinuteOfHour.Zero,                         21, MinuteOfHour.Zero),
                    CreateAdScheduleInfo(DayOfWeekEnum.Types.DayOfWeek.Tuesday,     18,
                                         MinuteOfHour.Zero,                         21, MinuteOfHour.Zero),
                    CreateAdScheduleInfo(DayOfWeekEnum.Types.DayOfWeek.Wednesday,   18,
                                         MinuteOfHour.Zero,                         21, MinuteOfHour.Zero),
                    CreateAdScheduleInfo(DayOfWeekEnum.Types.DayOfWeek.Thursday,    18,
                                         MinuteOfHour.Zero,                         21, MinuteOfHour.Zero),
                    CreateAdScheduleInfo(DayOfWeekEnum.Types.DayOfWeek.Friday,      18,
                                         MinuteOfHour.Zero,                         21, MinuteOfHour.Zero),
                }
            };

            operations.Add(new ExtensionFeedItemOperation()
            {
                Create = extensionFeedItem4
            });

            // Adds the ExtensionFeedItem.
            MutateExtensionFeedItemsResponse response =
                extensionFeedItemService.MutateExtensionFeedItems(customerId.ToString(),
                                                                  operations);

            Console.WriteLine($"Added {response.Results.Count}:");

            List <string> resourceNames = new List <string>();

            foreach (MutateExtensionFeedItemResult result in response.Results)
            {
                Console.WriteLine($"Created ExtensionFeedItems with " +
                                  $"resource name '{result.ResourceName}'.");
                resourceNames.Add(result.ResourceName);
            }
            return(resourceNames);
        }