Search in sources :

Example 11 with Proposal

use of com.google.api.ads.admanager.axis.v202111.Proposal 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.v202111.ProposalLineItem) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) ProposalLineItemPage(com.google.api.ads.admanager.axis.v202111.ProposalLineItemPage) ProposalLineItemServiceInterface(com.google.api.ads.admanager.axis.v202111.ProposalLineItemServiceInterface)

Example 12 with Proposal

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

the class CreateProposals method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param primarySalespersonId the ID of the primary salesperson.
 * @param primaryTraffickerId the ID of the primary trafficker.
 * @param programmaticBuyerId the ID of the programmatic buyer. This can be obtained through the
 *     Programmatic_Buyer PQL table.
 * @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 primarySalespersonId, long primaryTraffickerId, long programmaticBuyerId) throws RemoteException {
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    Proposal proposal = new Proposal();
    // Setting required Marketplace information.
    ProposalMarketplaceInfo proposalMarketplaceInfo = new ProposalMarketplaceInfo();
    proposalMarketplaceInfo.setBuyerAccountId(programmaticBuyerId);
    // Set common required fields for a proposal.
    proposal.setName("Proposal #" + new Random().nextInt(Integer.MAX_VALUE));
    proposal.setPrimaryTraffickerId(primaryTraffickerId);
    proposal.setMarketplaceInfo(proposalMarketplaceInfo);
    SalespersonSplit primarySalesperson = new SalespersonSplit();
    primarySalesperson.setUserId(primarySalespersonId);
    primarySalesperson.setSplit(100000);
    proposal.setPrimarySalesperson(primarySalesperson);
    // Create the proposal on the server.
    Proposal[] proposals = proposalService.createProposals(new Proposal[] { proposal });
    for (Proposal createdProposal : proposals) {
        System.out.printf("A proposal with ID %d and name '%s' " + "was created.%n", createdProposal.getId(), createdProposal.getName());
    }
}
Also used : ProposalServiceInterface(com.google.api.ads.admanager.axis.v202202.ProposalServiceInterface) Random(java.util.Random) ProposalMarketplaceInfo(com.google.api.ads.admanager.axis.v202202.ProposalMarketplaceInfo) SalespersonSplit(com.google.api.ads.admanager.axis.v202202.SalespersonSplit) Proposal(com.google.api.ads.admanager.axis.v202202.Proposal)

Example 13 with Proposal

use of com.google.api.ads.admanager.axis.v202111.Proposal 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 14 with Proposal

use of com.google.api.ads.admanager.axis.v202111.Proposal 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 15 with Proposal

use of com.google.api.ads.admanager.axis.v202111.Proposal 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.v202111.StatementBuilder)9 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)6 Proposal (com.google.api.ads.admanager.axis.v202108.Proposal)5 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202108.ProposalServiceInterface)5 Proposal (com.google.api.ads.admanager.axis.v202111.Proposal)5 ProposalLineItem (com.google.api.ads.admanager.axis.v202111.ProposalLineItem)5 ProposalLineItemServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalLineItemServiceInterface)5 Proposal (com.google.api.ads.admanager.axis.v202202.Proposal)5 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202202.ProposalServiceInterface)5 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 ProposalPage (com.google.api.ads.admanager.axis.v202108.ProposalPage)4 ProposalLineItemPage (com.google.api.ads.admanager.axis.v202111.ProposalLineItemPage)4 ProposalPage (com.google.api.ads.admanager.axis.v202111.ProposalPage)4 ProposalPage (com.google.api.ads.admanager.axis.v202202.ProposalPage)4 Random (java.util.Random)4 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)2 ProposalMarketplaceInfo (com.google.api.ads.admanager.axis.v202108.ProposalMarketplaceInfo)1 SalespersonSplit (com.google.api.ads.admanager.axis.v202108.SalespersonSplit)1 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1