Search in sources :

Example 6 with ProposalPage

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

Example 7 with ProposalPage

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

the class RequestBuyerAcceptance method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the proposal ID to send.
 * @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("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalId);
    // 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' will be sent to Marketplace for buyer " + "acceptance.%n", i++, proposal.getId(), proposal.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of proposals to be sent to Marketplace for buyer acceptance: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202202.RequestBuyerAcceptance action = new com.google.api.ads.admanager.axis.v202202.RequestBuyerAcceptance();
        // Perform action.
        UpdateResult result = proposalService.performProposalAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of proposals that were sent to Marketplace for buyer acceptance: %d%n", result.getNumChanges());
        } else {
            System.out.println("No proposals were sent to Marketplace for buyer acceptance.");
        }
    }
}
Also used : ProposalServiceInterface(com.google.api.ads.admanager.axis.v202202.ProposalServiceInterface) ProposalPage(com.google.api.ads.admanager.axis.v202202.ProposalPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202202.Proposal) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

Example 8 with ProposalPage

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

Example 9 with ProposalPage

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

Example 10 with ProposalPage

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

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 Proposal (com.google.api.ads.admanager.axis.v202108.Proposal)4 ProposalPage (com.google.api.ads.admanager.axis.v202108.ProposalPage)4 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202108.ProposalServiceInterface)4 Proposal (com.google.api.ads.admanager.axis.v202111.Proposal)4 ProposalPage (com.google.api.ads.admanager.axis.v202111.ProposalPage)4 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)4 Proposal (com.google.api.ads.admanager.axis.v202202.Proposal)4 ProposalPage (com.google.api.ads.admanager.axis.v202202.ProposalPage)4 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202202.ProposalServiceInterface)4 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)1