Search in sources :

Example 16 with StatementBuilder

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

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

Example 17 with StatementBuilder

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

the class GetAllSites 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 SiteService.
    SiteServiceInterface siteService = adManagerServices.get(session, SiteServiceInterface.class);
    // Create a statement to get all sites.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get sites by statement.
        SitePage page = siteService.getSitesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Site site : page.getResults()) {
                System.out.printf("%d) Site with ID %d and URL '%s' was found.%n", i++, site.getId(), site.getUrl());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : Site(com.google.api.ads.admanager.axis.v202111.Site) SitePage(com.google.api.ads.admanager.axis.v202111.SitePage) SiteServiceInterface(com.google.api.ads.admanager.axis.v202111.SiteServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)

Example 18 with StatementBuilder

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

the class UpdateTeams method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param teamId the ID of the team 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 teamId) throws RemoteException {
    // Get the TeamService.
    TeamServiceInterface teamService = adManagerServices.get(session, TeamServiceInterface.class);
    // Create a statement to only select a single team by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", teamId);
    // Get the team.
    TeamPage page = teamService.getTeamsByStatement(statementBuilder.toStatement());
    Team team = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    String newDescription = team.getDescription() + " - UPDATED";
    team.setDescription(newDescription);
    // Update the team on the server.
    Team[] teams = teamService.updateTeams(new Team[] { team });
    for (Team updatedTeam : teams) {
        System.out.printf("Team with ID %d and name '%s' was updated.%n", updatedTeam.getId(), updatedTeam.getName());
    }
}
Also used : TeamServiceInterface(com.google.api.ads.admanager.axis.v202111.TeamServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) TeamPage(com.google.api.ads.admanager.axis.v202111.TeamPage) Team(com.google.api.ads.admanager.axis.v202111.Team)

Example 19 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder 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.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 20 with StatementBuilder

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

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

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