Search in sources :

Example 6 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.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.v202111.UserTeamAssociationServiceInterface) UserTeamAssociation(com.google.api.ads.admanager.axis.v202111.UserTeamAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) UserTeamAssociationPage(com.google.api.ads.admanager.axis.v202111.UserTeamAssociationPage)

Example 7 with StatementBuilder

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

the class GetActiveActivities 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 {
    ActivityServiceInterface activityService = adManagerServices.get(session, ActivityServiceInterface.class);
    // Create a statement to select activities.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", ActivityStatus.ACTIVE.toString());
    // Retrieve a small amount of activities at a time, paging through
    // until all activities have been retrieved.
    int totalResultSetSize = 0;
    do {
        ActivityPage page = activityService.getActivitiesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each activity.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Activity activity : page.getResults()) {
                System.out.printf("%d) Activity with ID %d, name '%s', and type '%s' was found.%n", i++, activity.getId(), activity.getName(), activity.getType());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : ActivityPage(com.google.api.ads.admanager.axis.v202202.ActivityPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) ActivityServiceInterface(com.google.api.ads.admanager.axis.v202202.ActivityServiceInterface) Activity(com.google.api.ads.admanager.axis.v202202.Activity)

Example 8 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.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.v202111.ProposalPage) ProposalServiceInterface(com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202111.Proposal)

Example 9 with StatementBuilder

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

the class GetProposalsAwaitingSellerReview 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 {
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to select proposals.
    StatementBuilder statementBuilder = new StatementBuilder().where("negotiationStatus = :status").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", NegotiationStatus.AWAITING_SELLER_REVIEW.toString());
    // Retrieve a small amount of proposals at a time, paging through
    // until all proposals have been retrieved.
    int totalResultSetSize = 0;
    do {
        ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each proposal.
            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.v202111.ProposalPage) ProposalServiceInterface(com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202111.Proposal)

Example 10 with StatementBuilder

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

the class UpdateProposals method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the ID of the proposal 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 proposalId) throws RemoteException {
    // Get the ProposalService.
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to only select a single proposal by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", proposalId);
    // Get the proposal.
    ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.toStatement());
    Proposal proposal = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the proposal's notes.
    proposal.setInternalNotes("Proposal needs further review before approval.");
    // Update the proposal on the server.
    Proposal[] proposals = proposalService.updateProposals(new Proposal[] { proposal });
    for (Proposal updatedProposal : proposals) {
        System.out.printf("Proposal with ID %d and name '%s' was updated.%n", updatedProposal.getId(), updatedProposal.getName());
    }
}
Also used : ProposalPage(com.google.api.ads.admanager.axis.v202111.ProposalPage) ProposalServiceInterface(com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202111.Proposal)

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