4343import java .io .IOException ;
4444
4545/**
46- * Adds a feed that syncs feed items from a Google My Business (GMB) account and associates the feed
47- * with a customer.
46+ * Adds a feed that syncs feed items from a Business Profile account and associates the feed with a
47+ * customer.
4848 */
49- public class AddGoogleMyBusinessLocationExtensions {
49+ public class AddBusinessProfileLocationExtensions {
5050 // The required scope for setting the OAuth info.
5151 private final String GOOGLE_ADS_SCOPE = "https://www.googleapis.com/auth/adwords" ;
5252
5353 // The maximum number of CustomerFeed ADD operation attempts to make before throwing an exception.
5454 private static final int MAX_CUSTOMER_FEED_ADD_ATTEMPTS = 10 ;
5555
56- private static class AddGoogleMyBusinessLocationExtensionsParams extends CodeSampleParams {
56+ private static class AddBusinessProfileLocationExtensionsParams extends CodeSampleParams {
5757
5858 @ Parameter (names = ArgumentNames .CUSTOMER_ID , required = true )
5959 private Long customerId ;
6060
61- @ Parameter (names = ArgumentNames .GMB_EMAIL_ADDRESS , required = true )
62- private String gmbEmailAddress ;
61+ @ Parameter (names = ArgumentNames .BUSINESS_PROFILE_EMAIL_ADDRESS , required = true )
62+ private String businessProfileEmailAddress ;
6363
6464 @ Parameter (names = ArgumentNames .BUSINESS_ACCOUNT_IDENTIFIER )
6565 private String businessAccountIdentifier ;
6666
67- @ Parameter (names = ArgumentNames .GMB_ACCESS_TOKEN , required = true )
68- private String gmbAccessToken ;
67+ @ Parameter (names = ArgumentNames .BUSINESS_PROFILE_ACCESS_TOKEN , required = true )
68+ private String businessProfileAccessToken ;
6969 }
7070
7171 public static void main (String [] args ) throws InterruptedException , IOException {
72- AddGoogleMyBusinessLocationExtensionsParams params =
73- new AddGoogleMyBusinessLocationExtensionsParams ();
72+ AddBusinessProfileLocationExtensionsParams params =
73+ new AddBusinessProfileLocationExtensionsParams ();
7474
7575 if (!params .parseArguments (args )) {
7676
7777 // Either pass the required parameters for this example on the command line, or insert them
7878 // into the code here. See the parameter class definition above for descriptions.
7979 params .customerId = Long .parseLong ("INSERT_CUSTOMER_ID_HERE" );
80- params .gmbEmailAddress = "INSERT_GMB_EMAIL_ADDRESS_HERE " ;
80+ params .businessProfileEmailAddress = "INSERT_BUSINESS_PROFILE_EMAIL_ADDRESS_HERE " ;
8181 params .businessAccountIdentifier = "INSERT_BUSINESS_ACCOUNT_IDENTIFIER_HERE" ;
82- params .gmbAccessToken = "INSERT_GMB_ACCESS_TOKEN_HERE " ;
82+ params .businessProfileAccessToken = "INSERT_BUSINESS_PROFILE_ACCESS_TOKEN_HERE " ;
8383 }
8484
8585 GoogleAdsClient googleAdsClient = null ;
@@ -95,13 +95,13 @@ public static void main(String[] args) throws InterruptedException, IOException
9595 }
9696
9797 try {
98- new AddGoogleMyBusinessLocationExtensions ()
98+ new AddBusinessProfileLocationExtensions ()
9999 .runExample (
100100 googleAdsClient ,
101101 params .customerId ,
102- params .gmbEmailAddress ,
102+ params .businessProfileEmailAddress ,
103103 params .businessAccountIdentifier ,
104- params .gmbAccessToken );
104+ params .businessProfileAccessToken );
105105 } catch (GoogleAdsException gae ) {
106106 // GoogleAdsException is the base class for most exceptions thrown by an API request.
107107 // Instances of this exception have a message and a GoogleAdsFailure that contains a
@@ -123,61 +123,62 @@ public static void main(String[] args) throws InterruptedException, IOException
123123 *
124124 * @param googleAdsClient the Google Ads API client.
125125 * @param customerId the client customer ID.
126- * @param gmbEmailAddress email address associated with the GMB account.
127- * @param businessAccountIdentifier the account number of the GMB account (optional).
128- * @param gmbAccessToken the access token created using the 'AdWords' scope and the client ID and
129- * client secret of with the Cloud project associated with the GMB account.
126+ * @param businessProfileEmailAddress email address associated with the Business Profile account.
127+ * @param businessAccountIdentifier the account number of the Business Profile account (optional).
128+ * @param businessProfileAccessToken the access token created using the 'AdWords' scope and the
129+ * client ID and client secret of with the Cloud project associated with the Business Profile
130+ * account.
130131 * @throws GoogleAdsException if an API request failed with one or more service errors.
131132 * @throws InterruptedException if the Thread.sleep operation is interrupted.
132133 */
133134 private void runExample (
134135 GoogleAdsClient googleAdsClient ,
135136 long customerId ,
136- String gmbEmailAddress ,
137+ String businessProfileEmailAddress ,
137138 String businessAccountIdentifier ,
138- String gmbAccessToken )
139+ String businessProfileAccessToken )
139140 throws InterruptedException {
140- // Creates a PlacesLocationFeedData object to identify the Google My Business account, specify
141+ // Creates a PlacesLocationFeedData object to identify the Business Profile account, specify
141142 // location filters, and provide authorization for Google Ads to retrieve locations from the
142- // account on behalf of the user identified by gmbEmailAddress .
143+ // account on behalf of the user identified by businessProfileEmailAddress .
143144 PlacesLocationFeedData .Builder placesLocationFeedData =
144145 PlacesLocationFeedData .newBuilder ()
145- .setEmailAddress (gmbEmailAddress )
146- // Used to filter Google My Business listings by labels. If entries exist in
146+ .setEmailAddress (businessProfileEmailAddress )
147+ // Used to filter Business Profile listings by labels. If entries exist in
147148 // label_filters, only listings that have at least one of the labels set are
148149 // candidates to be synchronized into FeedItems. If no entries exist in
149150 // label_filters, then all listings are candidates for syncing.
150151 .addLabelFilters ("Stores in New York" )
151- // Sets the authentication info to be able to connect Google Ads to the GMB
152+ // Sets the authentication info to be able to connect Google Ads to the Business Profile
152153 // account.
153154 .setOauthInfo (
154155 OAuthInfo .newBuilder ()
155156 .setHttpMethod ("GET" )
156157 .setHttpRequestUrl (GOOGLE_ADS_SCOPE )
157- .setHttpAuthorizationHeader ("Bearer " + gmbAccessToken )
158+ .setHttpAuthorizationHeader ("Bearer " + businessProfileAccessToken )
158159 .build ());
159160
160161 if (businessAccountIdentifier != null ) {
161162 placesLocationFeedData .setBusinessAccountId (businessAccountIdentifier );
162163 }
163164
164- // [START add_google_my_business_location_extensions ]
165- // Creates a feed that will sync to the Google My Business account. Do not add FeedAttributes to
165+ // [START add_business_profile_location_extensions ]
166+ // Creates a feed that will sync to the Business Profile account. Do not add FeedAttributes to
166167 // this object as Google Ads will add them automatically because this will be a system generated
167168 // feed.
168- Feed .Builder gmbFeed =
169+ Feed .Builder businessProfileFeed =
169170 Feed .newBuilder ()
170- .setName ("Google My Business feed #" + getPrintableDateTime ())
171- // Configures the location feed populated from Google My Business Locations.
171+ .setName ("Business Profile feed #" + getPrintableDateTime ())
172+ // Configures the location feed populated from Business Profile Locations.
172173 .setPlacesLocationFeedData (placesLocationFeedData )
173174 // Since this feed's feed items will be managed by Google,
174175 // you must set its origin to GOOGLE.
175176 .setOrigin (FeedOrigin .GOOGLE );
176177
177- FeedOperation operation = FeedOperation .newBuilder ().setCreate (gmbFeed ).build ();
178- // [END add_google_my_business_location_extensions ]
178+ FeedOperation operation = FeedOperation .newBuilder ().setCreate (businessProfileFeed ).build ();
179+ // [END add_business_profile_location_extensions ]
179180
180- // [START add_google_my_business_location_extensions_1 ]
181+ // [START add_business_profile_location_extensions_1 ]
181182 try (FeedServiceClient feedServiceClient =
182183 googleAdsClient .getLatestVersion ().createFeedServiceClient ()) {
183184 // Adds the feed. Since it is a system generated feed, Google Ads will automatically:
@@ -186,16 +187,18 @@ private void runExample(
186187 // with the placeholder fields of the LOCATION placeholder type.
187188 MutateFeedsResponse response =
188189 feedServiceClient .mutateFeeds (Long .toString (customerId ), ImmutableList .of (operation ));
189- String gmbFeedResourceName = response .getResults (0 ).getResourceName ();
190- System .out .printf ("GMB feed created with resource name: %s%n" , gmbFeedResourceName );
191- // [END add_google_my_business_location_extensions_1]
190+ String businessProfileFeedResourceName = response .getResults (0 ).getResourceName ();
191+ System .out .printf (
192+ "Business Profile feed created with resource name: %s%n" ,
193+ businessProfileFeedResourceName );
194+ // [END add_business_profile_location_extensions_1]
192195
193- // [START add_google_my_business_location_extensions_2 ]
196+ // [START add_business_profile_location_extensions_2 ]
194197 // Adds a CustomerFeed that associates the feed with this customer for
195198 // the LOCATION placeholder type.
196199 CustomerFeed customerFeed =
197200 CustomerFeed .newBuilder ()
198- .setFeed (gmbFeedResourceName )
201+ .setFeed (businessProfileFeedResourceName )
199202 .addPlaceholderTypes (PlaceholderType .LOCATION )
200203 // Creates a matching function that will always evaluate to true.
201204 .setMatchingFunction (
@@ -212,14 +215,15 @@ private void runExample(
212215
213216 CustomerFeedOperation customerFeedOperation =
214217 CustomerFeedOperation .newBuilder ().setCreate (customerFeed ).build ();
215- // [END add_google_my_business_location_extensions_2 ]
218+ // [END add_business_profile_location_extensions_2 ]
216219
217- // [START add_google_my_business_location_extensions_3 ]
220+ // [START add_business_profile_location_extensions_3 ]
218221 try (CustomerFeedServiceClient customerFeedServiceClient =
219222 googleAdsClient .getLatestVersion ().createCustomerFeedServiceClient ()) {
220223
221224 // After the completion of the Feed ADD operation above the added feed will not be available
222- // for usage in a CustomerFeed until the sync between the Google Ads and GMB accounts
225+ // for usage in a CustomerFeed until the sync between the Google Ads and Business Profile
226+ // accounts
223227 // completes. The loop below will retry adding the CustomerFeed up to ten times with an
224228 // exponential back-off policy.
225229 String addedCustomerFeed = null ;
@@ -249,7 +253,7 @@ private void runExample(
249253 Thread .sleep (sleepSeconds * 1000 );
250254 }
251255 } while (numberOfAttempts < MAX_CUSTOMER_FEED_ADD_ATTEMPTS && addedCustomerFeed == null );
252- // [END add_google_my_business_location_extensions_3 ]
256+ // [END add_business_profile_location_extensions_3 ]
253257
254258 if (addedCustomerFeed == null ) {
255259 throw new RuntimeException (
0 commit comments