Esempio n. 1
0
        /// <summary>
        /// Deletes the active GMB customer feeds.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void DeleteEnabledGmbCustomerFeeds(AdWordsUser user)
        {
            CustomerFeedService customerFeedService = (CustomerFeedService)user.GetService(
                AdWordsService.v201705.CustomerFeedService);

            string query = "Select FeedId, PlaceholderTypes where PlaceholderTypes CONTAINS_ANY["
                           + PLACEHOLDER_LOCATION + "] AND Status = ENABLED";

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

            CustomerFeedPage page = customerFeedService.query(query);

            if (page != null && page.entries != null)
            {
                for (int i = 0; i < page.entries.Length; i++)
                {
                    CustomerFeed          customerFeed = page.entries[i];
                    CustomerFeedOperation operation    = new CustomerFeedOperation()
                    {
                        @operator = Operator.REMOVE,
                        operand   = customerFeed
                    };
                    operations.Add(operation);
                }
                customerFeedService.mutate(operations.ToArray());
            }
        }
        /// <summary>
        /// Creates a CustomerFeed that will associate the data holder's Feed with
        /// the ad customizer placeholder type.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="dataHolder">The data holder that contains metadata about
        /// the customizer Feed.</param>
        private static void CreateCustomerFeed(AdWordsUser user, CustomizersDataHolder dataHolder)
        {
            // Get the CustomerFeedService.
            CustomerFeedService customerFeedService = (CustomerFeedService)user.GetService(
                AdWordsService.v201406.CustomerFeedService);

            CustomerFeed customerFeed = new CustomerFeed();

            customerFeed.feedId           = dataHolder.FeedId;
            customerFeed.placeholderTypes = new int[] { PLACEHOLDER_AD_CUSTOMIZER };

            // Create a matching function that will always evaluate to true.
            Function        customerMatchingFunction = new Function();
            ConstantOperand constOperand             = new ConstantOperand();

            constOperand.type                   = ConstantOperandConstantType.BOOLEAN;
            constOperand.booleanValue           = true;
            customerMatchingFunction.lhsOperand = new FunctionArgumentOperand[] { constOperand };
            customerMatchingFunction.@operator  = FunctionOperator.IDENTITY;
            customerFeed.matchingFunction       = customerMatchingFunction;

            // Create an operation to add the customer feed.
            CustomerFeedOperation customerFeedOperation = new CustomerFeedOperation();

            customerFeedOperation.operand   = customerFeed;
            customerFeedOperation.@operator = Operator.ADD;

            CustomerFeed addedCustomerFeed = customerFeedService.mutate(
                new CustomerFeedOperation[] { customerFeedOperation }).value[0];

            Console.WriteLine("Customer feed for feed ID {0} was added.", addedCustomerFeed.feedId);
        }
 /// <summary>Snippet for GetCustomerFeed</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetCustomerFeedResourceNames()
 {
     // Create client
     CustomerFeedServiceClient customerFeedServiceClient = CustomerFeedServiceClient.Create();
     // Initialize request argument(s)
     CustomerFeedName resourceName = CustomerFeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]");
     // Make the request
     CustomerFeed response = customerFeedServiceClient.GetCustomerFeed(resourceName);
 }
Esempio n. 4
0
 /// <summary>Snippet for GetCustomerFeed</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetCustomerFeed()
 {
     // Create client
     CustomerFeedServiceClient customerFeedServiceClient = CustomerFeedServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER_ID]/customerFeeds/[FEED_ID]";
     // Make the request
     CustomerFeed response = customerFeedServiceClient.GetCustomerFeed(resourceName);
 }
        /// <summary>Snippet for GetCustomerFeedAsync</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 GetCustomerFeedAsync()
        {
            // Create client
            CustomerFeedServiceClient customerFeedServiceClient = await CustomerFeedServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER]/customerFeeds/[CUSTOMER_FEED]";
            // Make the request
            CustomerFeed response = await customerFeedServiceClient.GetCustomerFeedAsync(resourceName);
        }
Esempio n. 6
0
        /// <summary>Snippet for GetCustomerFeedAsync</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 GetCustomerFeedResourceNamesAsync()
        {
            // Create client
            CustomerFeedServiceClient customerFeedServiceClient = await CustomerFeedServiceClient.CreateAsync();

            // Initialize request argument(s)
            CustomerFeedName resourceName = CustomerFeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]");
            // Make the request
            CustomerFeed response = await customerFeedServiceClient.GetCustomerFeedAsync(resourceName);
        }
 /// <summary>Snippet for GetCustomerFeed</summary>
 public void GetCustomerFeedResourceNames()
 {
     // Snippet: GetCustomerFeed(CustomerFeedName, CallSettings)
     // Create client
     CustomerFeedServiceClient customerFeedServiceClient = CustomerFeedServiceClient.Create();
     // Initialize request argument(s)
     CustomerFeedName resourceName = CustomerFeedName.FromCustomerCustomerFeed("[CUSTOMER]", "[CUSTOMER_FEED]");
     // Make the request
     CustomerFeed response = customerFeedServiceClient.GetCustomerFeed(resourceName);
     // End snippet
 }
 /// <summary>Snippet for GetCustomerFeed</summary>
 public void GetCustomerFeed()
 {
     // Snippet: GetCustomerFeed(string, CallSettings)
     // Create client
     CustomerFeedServiceClient customerFeedServiceClient = CustomerFeedServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER]/customerFeeds/[CUSTOMER_FEED]";
     // Make the request
     CustomerFeed response = customerFeedServiceClient.GetCustomerFeed(resourceName);
     // End snippet
 }
Esempio n. 9
0
 /// <summary>Snippet for GetCustomerFeed</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetCustomerFeedRequestObject()
 {
     // Create client
     CustomerFeedServiceClient customerFeedServiceClient = CustomerFeedServiceClient.Create();
     // Initialize request argument(s)
     GetCustomerFeedRequest request = new GetCustomerFeedRequest
     {
         ResourceNameAsCustomerFeedName = CustomerFeedName.FromCustomerCustomerFeed("[CUSTOMER]", "[CUSTOMER_FEED]"),
     };
     // Make the request
     CustomerFeed response = customerFeedServiceClient.GetCustomerFeed(request);
 }
        /// <summary>Snippet for GetCustomerFeedAsync</summary>
        public async Task GetCustomerFeedAsync()
        {
            // Snippet: GetCustomerFeedAsync(string, CallSettings)
            // Additional: GetCustomerFeedAsync(string, CancellationToken)
            // Create client
            CustomerFeedServiceClient customerFeedServiceClient = await CustomerFeedServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/customerFeeds/[FEED_ID]";
            // Make the request
            CustomerFeed response = await customerFeedServiceClient.GetCustomerFeedAsync(resourceName);

            // End snippet
        }
        /// <summary>Snippet for GetCustomerFeedAsync</summary>
        public async Task GetCustomerFeedResourceNamesAsync()
        {
            // Snippet: GetCustomerFeedAsync(CustomerFeedName, CallSettings)
            // Additional: GetCustomerFeedAsync(CustomerFeedName, CancellationToken)
            // Create client
            CustomerFeedServiceClient customerFeedServiceClient = await CustomerFeedServiceClient.CreateAsync();

            // Initialize request argument(s)
            CustomerFeedName resourceName = CustomerFeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]");
            // Make the request
            CustomerFeed response = await customerFeedServiceClient.GetCustomerFeedAsync(resourceName);

            // End snippet
        }
 /// <summary>Snippet for GetCustomerFeed</summary>
 public void GetCustomerFeedRequestObject()
 {
     // Snippet: GetCustomerFeed(GetCustomerFeedRequest, CallSettings)
     // Create client
     CustomerFeedServiceClient customerFeedServiceClient = CustomerFeedServiceClient.Create();
     // Initialize request argument(s)
     GetCustomerFeedRequest request = new GetCustomerFeedRequest
     {
         ResourceNameAsCustomerFeedName = CustomerFeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"),
     };
     // Make the request
     CustomerFeed response = customerFeedServiceClient.GetCustomerFeed(request);
     // End snippet
 }
        /// <summary>Snippet for GetCustomerFeedAsync</summary>
        public async Task GetCustomerFeedRequestObjectAsync()
        {
            // Snippet: GetCustomerFeedAsync(GetCustomerFeedRequest, CallSettings)
            // Additional: GetCustomerFeedAsync(GetCustomerFeedRequest, CancellationToken)
            // Create client
            CustomerFeedServiceClient customerFeedServiceClient = await CustomerFeedServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetCustomerFeedRequest request = new GetCustomerFeedRequest
            {
                ResourceNameAsCustomerFeedName = CustomerFeedName.FromCustomerCustomerFeed("[CUSTOMER]", "[CUSTOMER_FEED]"),
            };
            // Make the request
            CustomerFeed response = await customerFeedServiceClient.GetCustomerFeedAsync(request);

            // End snippet
        }
Esempio n. 14
0
        /// <summary>
        /// Creates the customer feed.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="gmbFeedResourceName">Name of the GMB feed resource.</param>
        private static void CreateCustomerFeed(GoogleAdsClient client, long customerId,
                                               string gmbFeedResourceName)
        {
            // Get the CustomerFeedService.
            CustomerFeedServiceClient customerFeedService = client.GetService(
                Services.V3.CustomerFeedService);

            // Adds a CustomerFeed that associates the feed with this customer for
            // the LOCATION placeholder type.
            CustomerFeed customerFeed = new CustomerFeed()
            {
                Feed             = gmbFeedResourceName,
                PlaceholderTypes = { PlaceholderType.Location },
                MatchingFunction = new MatchingFunction()
                {
                    LeftOperands =
                    {
                        new Operand()
                        {
                            ConstantOperand = new ConstantOperand()
                            {
                                BooleanValue = true
                            }
                        }
                    },
                    // Specify the function string as IDENTITY(true) to mark this feed as enabled.
                    FunctionString = "IDENTITY(true)",
                    Operator       = MatchingFunctionOperator.Identity
                },
            };

            CustomerFeedOperation operation = new CustomerFeedOperation()
            {
                Create = customerFeed
            };

            MutateCustomerFeedsResponse customerFeedsResponse =
                customerFeedService.MutateCustomerFeeds(
                    customerId.ToString(), new[] { operation });

            // Displays the result.
            string addedCustomerFeed = customerFeedsResponse.Results[0].ResourceName;

            Console.WriteLine($"Customer feed created with resource name: {addedCustomerFeed}.");
            return;
        }
Esempio n. 15
0
        public void GetCustomerFeed2()
        {
            Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new Mock <CustomerFeedService.CustomerFeedServiceClient>(MockBehavior.Strict);
            GetCustomerFeedRequest request = new GetCustomerFeedRequest
            {
                ResourceName = new CustomerFeedName("[CUSTOMER]", "[CUSTOMER_FEED]").ToString(),
            };
            CustomerFeed expectedResponse = new CustomerFeed
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCustomerFeed(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CustomerFeedServiceClient client = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            CustomerFeed response            = client.GetCustomerFeed(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 16
0
        public async Task GetCustomerFeedAsync2()
        {
            Mock <CustomerFeedService.CustomerFeedServiceClient> mockGrpcClient = new Mock <CustomerFeedService.CustomerFeedServiceClient>(MockBehavior.Strict);
            GetCustomerFeedRequest request = new GetCustomerFeedRequest
            {
                ResourceName = new CustomerFeedName("[CUSTOMER]", "[CUSTOMER_FEED]").ToString(),
            };
            CustomerFeed expectedResponse = new CustomerFeed
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCustomerFeedAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CustomerFeed>(Task.FromResult(expectedResponse), null, null, null, null));
            CustomerFeedServiceClient client = new CustomerFeedServiceClientImpl(mockGrpcClient.Object, null);
            CustomerFeed response            = await client.GetCustomerFeedAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="gmbEmailAddress">The email address for Google My Business
        /// account.</param>
        /// <param name="gmbAccessToken">The OAuth2 access token for Google
        /// My Business account.</param>
        /// <param name="businessAccountIdentifier">The account identifier for
        /// Google My Business account.</param>
        public void Run(AdWordsUser user, string gmbEmailAddress, string gmbAccessToken,
        string businessAccountIdentifier)
        {
            FeedService feedService = (FeedService) user.GetService(AdWordsService.v201601.FeedService);

              CustomerFeedService customerFeedService = (CustomerFeedService) user.GetService(
              AdWordsService.v201601.CustomerFeedService);

              // Create a feed that will sync to the Google My Business account
              // specified by gmbEmailAddress. Do not add FeedAttributes to this object,
              // as AdWords will add them automatically because this will be a
              // system generated feed.
              Feed gmbFeed = new Feed();
              gmbFeed.name = String.Format("Google My Business feed #{0}",
              ExampleUtilities.GetRandomString());

              PlacesLocationFeedData feedData = new PlacesLocationFeedData();
              feedData.emailAddress = gmbEmailAddress;
              feedData.businessAccountIdentifier = businessAccountIdentifier;

              // Optional: specify labels to filter Google My Business listings. If
              // specified, only listings that have any of the labels set are
              // synchronized into FeedItems.
              feedData.labelFilters = new string[] { "Stores in New York City" };

              OAuthInfo oAuthInfo = new OAuthInfo();
              oAuthInfo.httpMethod = "GET";

              // Permissions for the AdWords API scope will also cover GMB.
              oAuthInfo.httpRequestUrl = user.Config.GetDefaultOAuth2Scope();
              oAuthInfo.httpAuthorizationHeader = string.Format("Bearer {0}", gmbAccessToken);
              feedData.oAuthInfo = oAuthInfo;

              gmbFeed.systemFeedGenerationData = feedData;

              // Since this feed's feed items will be managed by AdWords,
              // you must set its origin to ADWORDS.
              gmbFeed.origin = FeedOrigin.ADWORDS;

              // Create an operation to add the feed.
              FeedOperation feedOperation = new FeedOperation();
              feedOperation.operand = gmbFeed;
              feedOperation.@operator = Operator.ADD;

              try {
            // Add the feed. Since it is a system generated feed, AdWords will
            // automatically:
            // 1. Set up the FeedAttributes on the feed.
            // 2. Set up a FeedMapping that associates the FeedAttributes of the
            //    feed with the placeholder fields of the LOCATION placeholder
            //    type.
            FeedReturnValue addFeedResult = feedService.mutate(new FeedOperation[] { feedOperation });
            Feed addedFeed = addFeedResult.value[0];
            Console.WriteLine("Added GMB feed with ID {0}", addedFeed.id);

            // Add a CustomerFeed that associates the feed with this customer for
            // the LOCATION placeholder type.
            CustomerFeed customerFeed = new CustomerFeed();
            customerFeed.feedId = addedFeed.id;
            customerFeed.placeholderTypes = new int[] { PLACEHOLDER_LOCATION };

            // Create a matching function that will always evaluate to true.
            Function customerMatchingFunction = new Function();
            ConstantOperand constOperand = new ConstantOperand();
            constOperand.type = ConstantOperandConstantType.BOOLEAN;
            constOperand.booleanValue = true;
            customerMatchingFunction.lhsOperand = new FunctionArgumentOperand[] { constOperand };
            customerMatchingFunction.@operator = FunctionOperator.IDENTITY;
            customerFeed.matchingFunction = customerMatchingFunction;

            // Create an operation to add the customer feed.
            CustomerFeedOperation customerFeedOperation = new CustomerFeedOperation();
            customerFeedOperation.operand = customerFeed;
            customerFeedOperation.@operator = Operator.ADD;

            // After the completion of the Feed ADD operation above the added feed
            // will not be available for usage in a CustomerFeed until the sync
            // between the AdWords and GMB accounts completes.  The loop below
            // will retry adding the CustomerFeed up to ten times with an
            // exponential back-off policy.
            CustomerFeed addedCustomerFeed = null;

            AdWordsAppConfig config = new AdWordsAppConfig();
            config.RetryCount = 10;

            ErrorHandler errorHandler = new ErrorHandler(config);
            do {
              try {
            CustomerFeedReturnValue customerFeedResult =
                customerFeedService.mutate(new CustomerFeedOperation[] { customerFeedOperation });
            addedCustomerFeed = customerFeedResult.value[0];

            Console.WriteLine("Added CustomerFeed for feed ID {0} and placeholder type {1}",
                addedCustomerFeed.feedId, addedCustomerFeed.placeholderTypes[0]);
            break;
              } catch (AdWordsApiException e) {
            ApiException apiException = (ApiException) e.ApiException;
            foreach (ApiError error in apiException.errors) {
              if (error is CustomerFeedError) {
                if ((error as CustomerFeedError).reason ==
                    CustomerFeedErrorReason.MISSING_FEEDMAPPING_FOR_PLACEHOLDER_TYPE) {
                  errorHandler.DoExponentialBackoff();
                  errorHandler.IncrementRetriedAttempts();
                } else {
                  throw;
                }
              }
            }
              }
            } while (errorHandler.HaveMoreRetryAttemptsLeft());

            // OPTIONAL: Create a CampaignFeed to specify which FeedItems to use at
            // the Campaign level.  This will be similar to the CampaignFeed in the
            // AddSiteLinks example, except you can also filter based on the
            // business name and category of each FeedItem by using a
            // FeedAttributeOperand in your matching function.

            // OPTIONAL: Create an AdGroupFeed for even more fine grained control
            // over which feed items are used at the AdGroup level.
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to create customer feed.", e);
              }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="gmbEmailAddress">The email address for Google My Business
        /// account.</param>
        /// <param name="gmbAccessToken">The OAuth2 access token for Google
        /// My Business account.</param>
        /// <param name="businessAccountIdentifier">The account identifier for
        /// Google My Business account.</param>
        public void Run(AdWordsUser user, string gmbEmailAddress, string gmbAccessToken,
                        string businessAccountIdentifier)
        {
            FeedService feedService = (FeedService)user.GetService(AdWordsService.v201502.FeedService);

            CustomerFeedService customerFeedService = (CustomerFeedService)user.GetService(
                AdWordsService.v201502.CustomerFeedService);

            // Create a feed that will sync to the Google My Business account
            // specified by gmbEmailAddress. Do not add FeedAttributes to this object,
            // as AdWords will add them automatically because this will be a
            // system generated feed.
            Feed gmbFeed = new Feed();

            gmbFeed.name = String.Format("Google My Business feed #{0}",
                                         ExampleUtilities.GetRandomString());

            PlacesLocationFeedData feedData = new PlacesLocationFeedData();

            feedData.emailAddress = gmbEmailAddress;
            feedData.businessAccountIdentifier = businessAccountIdentifier;

            OAuthInfo oAuthInfo = new OAuthInfo();

            oAuthInfo.httpMethod = "GET";

            // Permissions for the AdWords API scope will also cover GMB.
            oAuthInfo.httpRequestUrl          = user.Config.GetDefaultOAuth2Scope();
            oAuthInfo.httpAuthorizationHeader = string.Format("Bearer {0}", gmbAccessToken);
            feedData.oAuthInfo = oAuthInfo;

            gmbFeed.systemFeedGenerationData = feedData;

            // Since this feed's feed items will be managed by AdWords,
            // you must set its origin to ADWORDS.
            gmbFeed.origin = FeedOrigin.ADWORDS;

            // Create an operation to add the feed.
            FeedOperation feedOperation = new FeedOperation();

            feedOperation.operand   = gmbFeed;
            feedOperation.@operator = Operator.ADD;

            try {
                // Add the feed. Since it is a system generated feed, AdWords will
                // automatically:
                // 1. Set up the FeedAttributes on the feed.
                // 2. Set up a FeedMapping that associates the FeedAttributes of the
                //    feed with the placeholder fields of the LOCATION placeholder
                //    type.
                FeedReturnValue addFeedResult = feedService.mutate(new FeedOperation[] { feedOperation });
                Feed            addedFeed     = addFeedResult.value[0];
                Console.WriteLine("Added GMB feed with ID {0}", addedFeed.id);

                // Add a CustomerFeed that associates the feed with this customer for
                // the LOCATION placeholder type.
                CustomerFeed customerFeed = new CustomerFeed();
                customerFeed.feedId           = addedFeed.id;
                customerFeed.placeholderTypes = new int[] { PLACEHOLDER_LOCATION };

                // Create a matching function that will always evaluate to true.
                Function        customerMatchingFunction = new Function();
                ConstantOperand constOperand             = new ConstantOperand();
                constOperand.type                   = ConstantOperandConstantType.BOOLEAN;
                constOperand.booleanValue           = true;
                customerMatchingFunction.lhsOperand = new FunctionArgumentOperand[] { constOperand };
                customerMatchingFunction.@operator  = FunctionOperator.IDENTITY;
                customerFeed.matchingFunction       = customerMatchingFunction;

                // Create an operation to add the customer feed.
                CustomerFeedOperation customerFeedOperation = new CustomerFeedOperation();
                customerFeedOperation.operand   = customerFeed;
                customerFeedOperation.@operator = Operator.ADD;

                // After the completion of the Feed ADD operation above the added feed
                // will not be available for usage in a CustomerFeed until the sync
                // between the AdWords and GMB accounts completes.  The loop below
                // will retry adding the CustomerFeed up to ten times with an
                // exponential back-off policy.
                CustomerFeed addedCustomerFeed = null;

                AdWordsAppConfig config = new AdWordsAppConfig();
                config.RetryCount = 10;

                ErrorHandler errorHandler = new ErrorHandler(config);
                do
                {
                    try {
                        CustomerFeedReturnValue customerFeedResult =
                            customerFeedService.mutate(new CustomerFeedOperation[] { customerFeedOperation });
                        addedCustomerFeed = customerFeedResult.value[0];

                        Console.WriteLine("Added CustomerFeed for feed ID {0} and placeholder type {1}",
                                          addedCustomerFeed.feedId, addedCustomerFeed.placeholderTypes[0]);
                        break;
                    } catch (AdWordsApiException e) {
                        ApiException apiException = (ApiException)e.ApiException;
                        foreach (ApiError error in apiException.errors)
                        {
                            if (error is CustomerFeedError)
                            {
                                if ((error as CustomerFeedError).reason ==
                                    CustomerFeedErrorReason.MISSING_FEEDMAPPING_FOR_PLACEHOLDER_TYPE)
                                {
                                    errorHandler.DoExponentialBackoff();
                                    errorHandler.IncrementRetriedAttempts();
                                }
                                else
                                {
                                    throw;
                                }
                            }
                        }
                    }
                } while (errorHandler.HaveMoreRetryAttemptsLeft());

                // OPTIONAL: Create a CampaignFeed to specify which FeedItems to use at
                // the Campaign level.  This will be similar to the CampaignFeed in the
                // AddSiteLinks example, except you can also filter based on the
                // business name and category of each FeedItem by using a
                // FeedAttributeOperand in your matching function.

                // OPTIONAL: Create an AdGroupFeed for even more fine grained control
                // over which feed items are used at the AdGroup level.
            } catch (Exception e) {
                throw new System.ApplicationException("Failed to create customer feed.", e);
            }
        }
        /// <summary>
        /// Add a CustomerFeed that associates the feed with this customer for
        /// the LOCATION placeholder type.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="feed">The GMB feed.</param>
        void AddCustomerFeed(AdWordsUser user, Feed feed)
        {
            using (CustomerFeedService customerFeedService = (CustomerFeedService)user.GetService(
                       AdWordsService.v201710.CustomerFeedService)) {
                // Add a CustomerFeed that associates the feed with this customer for
                // the LOCATION placeholder type.
                CustomerFeed customerFeed = new CustomerFeed();
                customerFeed.feedId           = feed.id;
                customerFeed.placeholderTypes = new int[] { PLACEHOLDER_LOCATION };

                // Create a matching function that will always evaluate to true.
                Function        customerMatchingFunction = new Function();
                ConstantOperand constOperand             = new ConstantOperand();
                constOperand.type                   = ConstantOperandConstantType.BOOLEAN;
                constOperand.booleanValue           = true;
                customerMatchingFunction.lhsOperand = new FunctionArgumentOperand[] { constOperand };
                customerMatchingFunction.@operator  = FunctionOperator.IDENTITY;
                customerFeed.matchingFunction       = customerMatchingFunction;

                // Create an operation to add the customer feed.
                CustomerFeedOperation customerFeedOperation = new CustomerFeedOperation();
                customerFeedOperation.operand   = customerFeed;
                customerFeedOperation.@operator = Operator.ADD;

                // After the completion of the Feed ADD operation above the added feed
                // will not be available for usage in a CustomerFeed until the sync
                // between the AdWords and GMB accounts completes.  The loop below
                // will retry adding the CustomerFeed up to ten times with an
                // exponential back-off policy.
                CustomerFeed addedCustomerFeed = null;

                AdWordsAppConfig config = new AdWordsAppConfig();
                config.RetryCount = 10;

                ErrorHandler errorHandler = new ErrorHandler(config);
                try {
                    do
                    {
                        try {
                            CustomerFeedReturnValue customerFeedResult =
                                customerFeedService.mutate(
                                    new CustomerFeedOperation[] { customerFeedOperation });
                            addedCustomerFeed = customerFeedResult.value[0];

                            Console.WriteLine("Added CustomerFeed for feed ID {0} and placeholder type {1}",
                                              addedCustomerFeed.feedId, addedCustomerFeed.placeholderTypes[0]);
                            break;
                        } catch (AdWordsApiException e) {
                            ApiException apiException = (ApiException)e.ApiException;
                            foreach (ApiError error in apiException.errors)
                            {
                                if (error is CustomerFeedError)
                                {
                                    if ((error as CustomerFeedError).reason ==
                                        CustomerFeedErrorReason.MISSING_FEEDMAPPING_FOR_PLACEHOLDER_TYPE)
                                    {
                                        errorHandler.DoExponentialBackoff();
                                        errorHandler.IncrementRetriedAttempts();
                                    }
                                    else
                                    {
                                        throw;
                                    }
                                }
                            }
                        }
                    } while (errorHandler.HaveMoreRetryAttemptsLeft());
                    // OPTIONAL: Create a CampaignFeed to specify which FeedItems to use at
                    // the Campaign level.  This will be similar to the CampaignFeed in the
                    // AddSiteLinks example, except you can also filter based on the
                    // business name and category of each FeedItem by using a
                    // FeedAttributeOperand in your matching function.

                    // OPTIONAL: Create an AdGroupFeed for even more fine grained control
                    // over which feed items are used at the AdGroup level.
                } catch (Exception e) {
                    throw new System.ApplicationException("Failed to create customer feed.", e);
                }
            }
        }