/// <summary>Snippet for MutateCustomerExtensionSettings</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateCustomerExtensionSettings() { // Create client CustomerExtensionSettingServiceClient customerExtensionSettingServiceClient = CustomerExtensionSettingServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <CustomerExtensionSettingOperation> operations = new CustomerExtensionSettingOperation[] { new CustomerExtensionSettingOperation(), }; // Make the request MutateCustomerExtensionSettingsResponse response = customerExtensionSettingServiceClient.MutateCustomerExtensionSettings(customerId, operations); }
/// <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="campaignId">ID of the campaign to targeting are added.</param> public void Run(GoogleAdsClient client, long customerId, long campaignId) { // Get the CustomerExtensionSettingServiceClient. CustomerExtensionSettingServiceClient customerExtensionSettingService = client.GetService(Services.V4.CustomerExtensionSettingService); try { // Creates an extension feed item as price. string extensionFeedItemResourceName = CreateExtensionFeedItem(client, customerId, campaignId); // Creates a customer extension setting using the previously created extension // feed item. This associates the price extension to your account. CustomerExtensionSetting customerExtensionSetting = new CustomerExtensionSetting() { ExtensionType = ExtensionType.Price, ExtensionFeedItems = { extensionFeedItemResourceName } }; // Creates an operation to add the extension setting. CustomerExtensionSettingOperation operation = new CustomerExtensionSettingOperation() { Create = customerExtensionSetting }; // Issues a mutate request to add the customer extension setting // and prints its information. MutateCustomerExtensionSettingsResponse response = customerExtensionSettingService.MutateCustomerExtensionSettings( customerId.ToString(), new[] { operation }); foreach (MutateCustomerExtensionSettingResult result in response.Results) { Console.WriteLine("Created customer extension setting 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; } }
/// <summary>Snippet for MutateCustomerExtensionSettingsAsync</summary> public async Task MutateCustomerExtensionSettingsAsync() { // Snippet: MutateCustomerExtensionSettingsAsync(string, IEnumerable<CustomerExtensionSettingOperation>, CallSettings) // Additional: MutateCustomerExtensionSettingsAsync(string, IEnumerable<CustomerExtensionSettingOperation>, CancellationToken) // Create client CustomerExtensionSettingServiceClient customerExtensionSettingServiceClient = await CustomerExtensionSettingServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <CustomerExtensionSettingOperation> operations = new CustomerExtensionSettingOperation[] { new CustomerExtensionSettingOperation(), }; // Make the request MutateCustomerExtensionSettingsResponse response = await customerExtensionSettingServiceClient.MutateCustomerExtensionSettingsAsync(customerId, operations); // End snippet }
/// <summary> /// Modifies SiteLink Extension at Customer Level /// </summary> /// <param name="user">Adwords User Object</param> /// <param name="sitelinkFeedItem">SiteLinkFeedItem with Details</param> /// <returns>Updated CustomerExtensionSettings</returns> public CustomerExtensionSetting UpdateSiteLinkAtCustomerLevelUsingCustExtSetService(AdWordsUser user, SitelinkFeedItem sitelinkFeedItem) { CustomerExtensionSettingService customerExtensionSettingService = (CustomerExtensionSettingService)user.GetService(AdWordsService.v201809.CustomerExtensionSettingService); ExtensionFeedItem[] extensionFeedItems = new[] { sitelinkFeedItem }; ExtensionSetting extensionSetting = new ExtensionSetting(); extensionSetting.extensions = extensionFeedItems; CustomerExtensionSetting customerExtensionSetting = new CustomerExtensionSetting(); customerExtensionSetting.extensionType = FeedType.SITELINK; customerExtensionSetting.extensionSetting = extensionSetting; CustomerExtensionSettingOperation modifyOperation = new CustomerExtensionSettingOperation(); modifyOperation.operand = customerExtensionSetting; modifyOperation.@operator = Operator.SET; try { CustomerExtensionSettingReturnValue returnValue = customerExtensionSettingService.mutate(new[] { modifyOperation }); if (returnValue.value != null && returnValue.value.Length > 0) { CustomerExtensionSetting modifiedExtensionSetting = returnValue.value[0]; Logger.Log(Logger.LogType.INFO, "Modification Successful for Feed(ID): " + sitelinkFeedItem.feedId + " with FeedItem(ID): " + sitelinkFeedItem.feedItemId); return(modifiedExtensionSetting); } else { Logger.Log(Logger.LogType.WARNING, "Nothing Modified for Feed(ID): " + sitelinkFeedItem.feedId + " with FeedItem(ID): " + sitelinkFeedItem.feedItemId); return(null); } } catch (AdWordsApiException ex) { Logger.Log(Logger.LogType.EXCEPTION, Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException); return(null); } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="campaignId">Id of the campaign to which sitelinks will /// be added.</param> public void Run(AdWordsUser user, long campaignId) { using (CustomerExtensionSettingService customerExtensionSettingService = (CustomerExtensionSettingService)user.GetService(AdWordsService.v201802 .CustomerExtensionSettingService)) { // Create the price extension feed item. PriceFeedItem priceFeedItem = new PriceFeedItem() { priceExtensionType = PriceExtensionType.SERVICES, // Price qualifier is optional. priceQualifier = PriceExtensionPriceQualifier.FROM, trackingUrlTemplate = "http://tracker.example.com/?u={lpurl}", language = "en", campaignTargeting = new FeedItemCampaignTargeting() { TargetingCampaignId = campaignId, }, scheduling = new FeedItemSchedule[] { new FeedItemSchedule() { dayOfWeek = DayOfWeek.SATURDAY, startHour = 10, startMinute = MinuteOfHour.ZERO, endHour = 22, endMinute = MinuteOfHour.ZERO }, new FeedItemSchedule() { dayOfWeek = DayOfWeek.SUNDAY, startHour = 10, startMinute = MinuteOfHour.ZERO, endHour = 18, endMinute = MinuteOfHour.ZERO } } }; // To create a price extension, at least three table rows are needed. List <PriceTableRow> priceTableRows = new List <PriceTableRow>(); string currencyCode = "USD"; priceTableRows.Add(CreatePriceTableRow("Scrubs", "Body Scrub, Salt Scrub", "http://www.example.com/scrubs", "http://m.example.com/scrubs", 60000000, currencyCode, PriceExtensionPriceUnit.PER_HOUR)); priceTableRows.Add(CreatePriceTableRow("Hair Cuts", "Once a month", "http://www.example.com/haircuts", "http://m.example.com/haircuts", 75000000, currencyCode, PriceExtensionPriceUnit.PER_MONTH)); priceTableRows.Add(CreatePriceTableRow("Skin Care Package", "Four times a month", "http://www.example.com/skincarepackage", null, 250000000, currencyCode, PriceExtensionPriceUnit.PER_MONTH)); priceFeedItem.tableRows = priceTableRows.ToArray(); // Create your campaign extension settings. This associates the sitelinks // to your campaign. CustomerExtensionSetting customerExtensionSetting = new CustomerExtensionSetting() { extensionType = FeedType.PRICE, extensionSetting = new ExtensionSetting() { extensions = new ExtensionFeedItem[] { priceFeedItem } } }; CustomerExtensionSettingOperation operation = new CustomerExtensionSettingOperation() { operand = customerExtensionSetting, @operator = Operator.ADD }; try { // Add the extensions. CustomerExtensionSettingReturnValue retVal = customerExtensionSettingService.mutate( new CustomerExtensionSettingOperation[] { operation }); if (retVal.value != null && retVal.value.Length > 0) { CustomerExtensionSetting newExtensionSetting = retVal.value[0]; Console.WriteLine("Extension setting with type '{0}' was added.", newExtensionSetting.extensionType); } else { Console.WriteLine("No extension settings were created."); } } catch (Exception e) { throw new System.ApplicationException("Failed to create extension settings.", e); } } }