Search in sources :

Example 1 with LocationCriterionServiceInterface

use of com.google.api.ads.adwords.axis.v201809.cm.LocationCriterionServiceInterface 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());
    }
}
Also used : SelectorBuilder(com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder) LocationCriterion(com.google.api.ads.adwords.axis.v201809.cm.LocationCriterion) LocationCriterionServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.LocationCriterionServiceInterface) Selector(com.google.api.ads.adwords.axis.v201809.cm.Selector)

Aggregations

SelectorBuilder (com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder)1 LocationCriterion (com.google.api.ads.adwords.axis.v201809.cm.LocationCriterion)1 LocationCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.LocationCriterionServiceInterface)1 Selector (com.google.api.ads.adwords.axis.v201809.cm.Selector)1