Search in sources :

Example 86 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202205.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.v202202.Site) SitePage(com.google.api.ads.admanager.axis.v202202.SitePage) SiteServiceInterface(com.google.api.ads.admanager.axis.v202202.SiteServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)

Example 87 with StatementBuilder

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

the class GetSitesRequiringApproval 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 select sites needing approval.
    StatementBuilder statementBuilder = new StatementBuilder().where("approvalStatus = :approvalStatus").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("approvalStatus", ApprovalStatus.REQUIRES_REVIEW.toString());
    // 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.v202202.Site) SitePage(com.google.api.ads.admanager.axis.v202202.SitePage) SiteServiceInterface(com.google.api.ads.admanager.axis.v202202.SiteServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)

Example 88 with StatementBuilder

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

the class ApproveSuggestedAdUnits method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param numRequests the number of requests for suggested ad units greater than which to approve.
 * @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 numRequests) throws RemoteException {
    // Get the SuggestedAdUnitService.
    SuggestedAdUnitServiceInterface suggestedAdUnitService = adManagerServices.get(session, SuggestedAdUnitServiceInterface.class);
    // Create a statement to only select suggested ad units that are highly
    // requested.
    StatementBuilder statementBuilder = new StatementBuilder().where("numRequests >= :numRequests").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("numRequests", numRequests);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get suggested ad units by statement.
        SuggestedAdUnitPage page = suggestedAdUnitService.getSuggestedAdUnitsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (SuggestedAdUnit suggestedAdUnit : page.getResults()) {
                System.out.printf("%d) Suggested ad unit with ID '%s' will be approved.%n", i++, suggestedAdUnit.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of suggested ad units to be approved: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202202.ApproveSuggestedAdUnits action = new com.google.api.ads.admanager.axis.v202202.ApproveSuggestedAdUnits();
        // Perform action.
        SuggestedAdUnitUpdateResult result = suggestedAdUnitService.performSuggestedAdUnitAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of new ad units created: %d%n", result.getNewAdUnitIds().length);
        } else {
            System.out.println("No suggested ad units were approved.");
        }
    }
}
Also used : SuggestedAdUnitUpdateResult(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnitUpdateResult) SuggestedAdUnitServiceInterface(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnitServiceInterface) SuggestedAdUnit(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnit) SuggestedAdUnitPage(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnitPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)

Example 89 with StatementBuilder

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

the class GetAllSuggestedAdUnits 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 SuggestedAdUnitService.
    SuggestedAdUnitServiceInterface suggestedAdUnitService = adManagerServices.get(session, SuggestedAdUnitServiceInterface.class);
    // Create a statement to select all suggested ad units.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get suggested ad units by statement.
        SuggestedAdUnitPage page = suggestedAdUnitService.getSuggestedAdUnitsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (SuggestedAdUnit suggestedAdUnit : page.getResults()) {
                System.out.printf("%d) Suggested ad unit with ID '%s', path '%s', " + "and number of requests %d was found.%n", i++, suggestedAdUnit.getId(), Joiner.on('/').join(suggestedAdUnit.getPath()), suggestedAdUnit.getNumRequests());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) SuggestedAdUnitServiceInterface(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnitServiceInterface) SuggestedAdUnit(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnit) SuggestedAdUnitPage(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnitPage)

Example 90 with StatementBuilder

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

the class GetHighlyRequestedSuggestedAdUnits method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param numRequests the number of requests.
 * @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 numRequests) throws RemoteException {
    SuggestedAdUnitServiceInterface suggestedAdUnitService = adManagerServices.get(session, SuggestedAdUnitServiceInterface.class);
    // Create a statement to select suggested ad units.
    StatementBuilder statementBuilder = new StatementBuilder().where("numRequests >= :numRequests").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("numRequests", numRequests);
    // Retrieve a small amount of suggested ad units at a time, paging through
    // until all suggested ad units have been retrieved.
    int totalResultSetSize = 0;
    do {
        SuggestedAdUnitPage page = suggestedAdUnitService.getSuggestedAdUnitsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each suggested ad unit.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (SuggestedAdUnit suggestedAdUnit : page.getResults()) {
                System.out.printf("%d) Suggested ad unit with ID '%s' and num requests %d was found.%n", i++, suggestedAdUnit.getId(), suggestedAdUnit.getNumRequests());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) SuggestedAdUnitServiceInterface(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnitServiceInterface) SuggestedAdUnit(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnit) SuggestedAdUnitPage(com.google.api.ads.admanager.axis.v202202.SuggestedAdUnitPage)

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 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)120 ArrayList (java.util.ArrayList)24 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 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)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 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 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface)5