Search in sources :

Example 16 with ProposalLineItemPage

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

the class UpdateProposalLineItems method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalLineItemId the ID of the proposal line item 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 proposalLineItemId) throws RemoteException {
    // Get the ProposalLineItemService.
    ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
    // Create a statement to select a proposal line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalLineItemId);
    // Get the proposal line item.
    ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(statementBuilder.toStatement());
    ProposalLineItem proposalLineItem = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the proposal line item's note field.
    proposalLineItem.setInternalNotes("Proposal line item ready for submission.");
    // Update the proposal line item on the server.
    ProposalLineItem[] proposalLineItems = proposalLineItemService.updateProposalLineItems(new ProposalLineItem[] { proposalLineItem });
    for (ProposalLineItem updatedProposalLineItem : proposalLineItems) {
        System.out.printf("Proposal line item with ID %d and name '%s' was updated.%n", updatedProposalLineItem.getId(), updatedProposalLineItem.getName());
    }
}
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)

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 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)4 ProposalLineItem (com.google.api.ads.admanager.axis.v202108.ProposalLineItem)4 ProposalLineItemPage (com.google.api.ads.admanager.axis.v202108.ProposalLineItemPage)4 ProposalLineItemServiceInterface (com.google.api.ads.admanager.axis.v202108.ProposalLineItemServiceInterface)4 ProposalLineItem (com.google.api.ads.admanager.axis.v202111.ProposalLineItem)4 ProposalLineItemPage (com.google.api.ads.admanager.axis.v202111.ProposalLineItemPage)4 ProposalLineItemServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalLineItemServiceInterface)4 ProposalLineItem (com.google.api.ads.admanager.axis.v202202.ProposalLineItem)4 ProposalLineItemPage (com.google.api.ads.admanager.axis.v202202.ProposalLineItemPage)4 ProposalLineItemServiceInterface (com.google.api.ads.admanager.axis.v202202.ProposalLineItemServiceInterface)4 ProposalLineItem (com.google.api.ads.admanager.axis.v202205.ProposalLineItem)4 ProposalLineItemPage (com.google.api.ads.admanager.axis.v202205.ProposalLineItemPage)4 ProposalLineItemServiceInterface (com.google.api.ads.admanager.axis.v202205.ProposalLineItemServiceInterface)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 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)1