Search in sources :

Example 61 with StatementBuilder

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

the class GetUserTeamAssociationsForUser method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param userId the user 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 userId) throws RemoteException {
    UserTeamAssociationServiceInterface userTeamAssociationService = adManagerServices.get(session, UserTeamAssociationServiceInterface.class);
    // Create a statement to select user team associations.
    StatementBuilder statementBuilder = new StatementBuilder().where("userId = :userId").orderBy("userId ASC, teamId ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("userId", userId);
    // Retrieve a small amount of user team associations at a time, paging through
    // until all user team associations have been retrieved.
    int totalResultSetSize = 0;
    do {
        UserTeamAssociationPage page = userTeamAssociationService.getUserTeamAssociationsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each user team association.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (UserTeamAssociation userTeamAssociation : page.getResults()) {
                System.out.printf("%d) User team association with user ID %d and team ID %d was found.%n", i++, userTeamAssociation.getUserId(), userTeamAssociation.getTeamId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : UserTeamAssociationServiceInterface(com.google.api.ads.admanager.axis.v202205.UserTeamAssociationServiceInterface) UserTeamAssociation(com.google.api.ads.admanager.axis.v202205.UserTeamAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) UserTeamAssociationPage(com.google.api.ads.admanager.axis.v202205.UserTeamAssociationPage)

Example 62 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202205.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.v202205.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202205.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202205.PlacementServiceInterface)

Example 63 with StatementBuilder

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

the class GetProposalLineItemsForProposal method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the ID of the proposal.
 * @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 proposalId) throws RemoteException {
    ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
    // Create a statement to select proposal line items.
    StatementBuilder statementBuilder = new StatementBuilder().where("proposalId = :proposalId").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("proposalId", proposalId);
    // Retrieve a small amount of proposal line items at a time, paging through
    // until all proposal line items have been retrieved.
    int totalResultSetSize = 0;
    do {
        ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each proposal line item.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (ProposalLineItem proposalLineItem : page.getResults()) {
                System.out.printf("%d) Proposal line item with ID %d and name '%s' was found.%n", i++, proposalLineItem.getId(), proposalLineItem.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : ProposalLineItem(com.google.api.ads.admanager.axis.v202205.ProposalLineItem) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) ProposalLineItemPage(com.google.api.ads.admanager.axis.v202205.ProposalLineItemPage) ProposalLineItemServiceInterface(com.google.api.ads.admanager.axis.v202205.ProposalLineItemServiceInterface)

Example 64 with StatementBuilder

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

the class GetAllProposals 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 ProposalService.
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to select all proposals.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get proposals by statement.
        ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Proposal proposal : page.getResults()) {
                System.out.printf("%d) Proposal with ID %d and name '%s' was found.%n", i++, proposal.getId(), proposal.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : ProposalPage(com.google.api.ads.admanager.axis.v202205.ProposalPage) ProposalServiceInterface(com.google.api.ads.admanager.axis.v202205.ProposalServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202205.Proposal)

Example 65 with StatementBuilder

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

the class GetMarketplaceComments method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the proposal 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 proposalId) throws RemoteException {
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to select marketplace comments.
    StatementBuilder statementBuilder = new StatementBuilder().where("proposalId = :proposalId").withBindVariableValue("proposalId", proposalId);
    MarketplaceCommentPage page = proposalService.getMarketplaceCommentsByStatement(statementBuilder.toStatement());
    if (page.getResults() != null) {
        // Print out some information for each marketplace comment.
        int i = page.getStartIndex();
        for (MarketplaceComment marketplaceComment : page.getResults()) {
            System.out.printf("%d) Marketplace comment with creation time '%s' and comment '%s' was found.%n", i++, DateTimes.toString(marketplaceComment.getCreationTime()), marketplaceComment.getComment());
        }
    } else {
        System.out.println("No marketplace comments found.");
    }
}
Also used : MarketplaceCommentPage(com.google.api.ads.admanager.axis.v202205.MarketplaceCommentPage) ProposalServiceInterface(com.google.api.ads.admanager.axis.v202205.ProposalServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) MarketplaceComment(com.google.api.ads.admanager.axis.v202205.MarketplaceComment)

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 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)120 ArrayList (java.util.ArrayList)24 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 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)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 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 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface)5