Search in sources :

Example 21 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder in project googleads-java-lib by googleads.

the class GetAllPlacements method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @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(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the PlacementService.
    PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
    // Create a statement to get all placements.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get placements by statement.
        PlacementPage page = placementService.getPlacementsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Placement placement : page.getResults()) {
                System.out.printf("%d) Placement with ID %d and name '%s' was found.%n", i++, placement.getId(), placement.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202111.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202111.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202111.PlacementServiceInterface)

Example 22 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder in project googleads-java-lib by googleads.

the class UpdatePlacements method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param placementId the ID of the placement to update.
 * @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(AdManagerServices adManagerServices, AdManagerSession session, long placementId) throws RemoteException {
    // Get the PlacementService.
    PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
    // Create a statement to only select a single placement by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", placementId);
    // Get the placement.
    PlacementPage page = placementService.getPlacementsByStatement(statementBuilder.toStatement());
    Placement placement = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    placement.setDescription("This placement contains all leaderboards.");
    // Update the placement on the server.
    Placement[] placements = placementService.updatePlacements(new Placement[] { placement });
    for (Placement updatedPlacement : placements) {
        System.out.printf("Placement with ID %d and name '%s' was updated.%n", updatedPlacement.getId(), updatedPlacement.getName());
    }
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202111.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202111.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202111.PlacementServiceInterface)

Example 23 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder in project googleads-java-lib by googleads.

the class UpdateActivityGroups method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param activityGroupId the ID of the activity group to update.
 * @param advertiserCompanyId the ID of the company to associate with the activity group.
 * @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(AdManagerServices adManagerServices, AdManagerSession session, long activityGroupId, long advertiserCompanyId) throws RemoteException {
    // Get the ActivityGroupService.
    ActivityGroupServiceInterface activityGroupService = adManagerServices.get(session, ActivityGroupServiceInterface.class);
    // Create a statement to only select a single activity group by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", activityGroupId);
    // Get the activity group.
    ActivityGroupPage page = activityGroupService.getActivityGroupsByStatement(statementBuilder.toStatement());
    ActivityGroup activityGroup = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the companies.
    activityGroup.setCompanyIds(Longs.concat(activityGroup.getCompanyIds(), new long[] { advertiserCompanyId }));
    // Update the activity group on the server.
    ActivityGroup[] activityGroups = activityGroupService.updateActivityGroups(new ActivityGroup[] { activityGroup });
    for (ActivityGroup updatedActivityGroup : activityGroups) {
        System.out.printf("Activity group with ID %d and name '%s' was updated.%n", updatedActivityGroup.getId(), updatedActivityGroup.getName());
    }
}
Also used : ActivityGroupServiceInterface(com.google.api.ads.admanager.axis.v202202.ActivityGroupServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) ActivityGroup(com.google.api.ads.admanager.axis.v202202.ActivityGroup) ActivityGroupPage(com.google.api.ads.admanager.axis.v202202.ActivityGroupPage)

Example 24 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder in project googleads-java-lib by googleads.

the class GetAllTargetingPresets method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @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(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the TargetingPresetService.
    TargetingPresetServiceInterface targetingPresetService = adManagerServices.get(session, TargetingPresetServiceInterface.class);
    // Create a statement to get all targeting presets.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get targeting presets by statement.
        TargetingPresetPage page = targetingPresetService.getTargetingPresetsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (TargetingPreset targetingPreset : page.getResults()) {
                System.out.printf("%d) Targeting preset with ID %d and name '%s' was found.%n", i++, targetingPreset.getId(), targetingPreset.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : TargetingPresetServiceInterface(com.google.api.ads.admanager.axis.v202111.TargetingPresetServiceInterface) TargetingPresetPage(com.google.api.ads.admanager.axis.v202111.TargetingPresetPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) TargetingPreset(com.google.api.ads.admanager.axis.v202111.TargetingPreset)

Example 25 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder in project googleads-java-lib by googleads.

the class UpdateLicas method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param lineItemId the line item ID of the LICA.
 * @param creativeId the master or creative set ID of the LICA. For creative sets, set the master
 *     creative ID.
 * @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(AdManagerServices adManagerServices, AdManagerSession session, long lineItemId, long creativeId) throws RemoteException {
    // Get the LineItemCreativeAssociationService.
    LineItemCreativeAssociationServiceInterface licaService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
    // Create a statement to select a single LICA for a line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("lineItemId = :lineItemId AND creativeId = :creativeId").orderBy("lineItemId ASC, creativeId ASC").limit(1).withBindVariableValue("lineItemId", lineItemId).withBindVariableValue("creativeId", creativeId);
    // Get the LICA.
    LineItemCreativeAssociationPage page = licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
    LineItemCreativeAssociation lica = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the destination URL.
    lica.setDestinationUrl("http://news.google.com?newTrackingParameter");
    // Update the LICA on the server.
    LineItemCreativeAssociation[] licas = licaService.updateLineItemCreativeAssociations(new LineItemCreativeAssociation[] { lica });
    for (LineItemCreativeAssociation updatedLica : licas) {
        System.out.printf("LICA with line item ID %d and creative ID %d was updated.%n", updatedLica.getLineItemId(), updatedLica.getCreativeId());
    }
}
Also used : LineItemCreativeAssociation(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationPage) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationServiceInterface)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)120 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)120 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)120 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)18 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)18 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)18 ArrayList (java.util.ArrayList)18 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202108.CustomTargetingServiceInterface)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202108.InventoryServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202108.PublisherQueryLanguageServiceInterface)8 ResultSet (com.google.api.ads.admanager.axis.v202108.ResultSet)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202202.InventoryServiceInterface)8 AdUnit (com.google.api.ads.admanager.axis.v202108.AdUnit)7 AdUnitPage (com.google.api.ads.admanager.axis.v202108.AdUnitPage)7 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202202.CustomTargetingServiceInterface)6 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202111.CustomTargetingServiceInterface)5 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface)5 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)5 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)5 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)5