use of com.google.api.ads.adwords.axis.v201809.cm.LocationCriterion in project googleads-java-lib by googleads.
the class LookupLocation method runExample.
/**
* Runs the example.
*
* @param adWordsServices the services factory.
* @param session the session.
* @param locationNames the location names to use for the lookup.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session, String[] locationNames) throws RemoteException {
// Get the LocationCriterionService.
LocationCriterionServiceInterface locationCriterionService = adWordsServices.get(session, LocationCriterionServiceInterface.class);
Selector selector = new SelectorBuilder().fields("Id", "LocationName", "CanonicalName", "DisplayType", "ParentLocations", "Reach", "TargetingStatus").in("LocationName", locationNames).equals("Locale", "en").build();
// Make the get request.
LocationCriterion[] locationCriteria = locationCriterionService.get(selector);
// Display the resulting location criteria.
for (LocationCriterion locationCriterion : locationCriteria) {
String parentString = getParentLocationString(locationCriterion.getLocation().getParentLocations());
System.out.printf("The search term '%s' returned the location '%s (%d)' of type '%s' " + "with parent locations '%s' and reach %d (%s).%n", locationCriterion.getSearchTerm(), locationCriterion.getLocation().getLocationName(), locationCriterion.getLocation().getId(), locationCriterion.getLocation().getDisplayType(), parentString, locationCriterion.getReach(), locationCriterion.getLocation().getTargetingStatus());
}
}
Aggregations