Search in sources :

Example 6 with SiteServiceInterface

use of com.google.api.ads.admanager.axis.v202202.SiteServiceInterface 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 7 with SiteServiceInterface

use of com.google.api.ads.admanager.axis.v202202.SiteServiceInterface 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 8 with SiteServiceInterface

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

the class SubmitSiteForApproval method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param siteId the ID of the site to submit for approval.
 * @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 siteId) throws RemoteException {
    // Get the SiteService.
    SiteServiceInterface siteService = adManagerServices.get(session, SiteServiceInterface.class);
    // Create a statement to select a site.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", siteId);
    // 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 will be submitted for approval.%n", i++, site.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of sites to be submitted: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202202.SubmitSiteForApproval action = new com.google.api.ads.admanager.axis.v202202.SubmitSiteForApproval();
        // Perform action.
        UpdateResult result = siteService.performSiteAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of sites submitted: %d%n", result.getNumChanges());
        } else {
            System.out.println("No sites were submitted.");
        }
    }
}
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) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

Example 9 with SiteServiceInterface

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

the class SubmitSiteForApproval method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param siteId the ID of the site to submit for approval.
 * @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 siteId) throws RemoteException {
    // Get the SiteService.
    SiteServiceInterface siteService = adManagerServices.get(session, SiteServiceInterface.class);
    // Create a statement to select a site.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", siteId);
    // 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 will be submitted for approval.%n", i++, site.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of sites to be submitted: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202108.SubmitSiteForApproval action = new com.google.api.ads.admanager.axis.v202108.SubmitSiteForApproval();
        // Perform action.
        UpdateResult result = siteService.performSiteAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of sites submitted: %d%n", result.getNumChanges());
        } else {
            System.out.println("No sites were submitted.");
        }
    }
}
Also used : Site(com.google.api.ads.admanager.axis.v202108.Site) SitePage(com.google.api.ads.admanager.axis.v202108.SitePage) SiteServiceInterface(com.google.api.ads.admanager.axis.v202108.SiteServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202108.UpdateResult)

Example 10 with SiteServiceInterface

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

Aggregations

Site (com.google.api.ads.admanager.axis.v202108.Site)4 SiteServiceInterface (com.google.api.ads.admanager.axis.v202108.SiteServiceInterface)4 Site (com.google.api.ads.admanager.axis.v202111.Site)4 SiteServiceInterface (com.google.api.ads.admanager.axis.v202111.SiteServiceInterface)4 Site (com.google.api.ads.admanager.axis.v202202.Site)4 SiteServiceInterface (com.google.api.ads.admanager.axis.v202202.SiteServiceInterface)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)3 SitePage (com.google.api.ads.admanager.axis.v202108.SitePage)3 SitePage (com.google.api.ads.admanager.axis.v202111.SitePage)3 SitePage (com.google.api.ads.admanager.axis.v202202.SitePage)3 ChildPublisher (com.google.api.ads.admanager.axis.v202108.ChildPublisher)1 Network (com.google.api.ads.admanager.axis.v202108.Network)1 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202108.NetworkServiceInterface)1 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1 ChildPublisher (com.google.api.ads.admanager.axis.v202111.ChildPublisher)1 Network (com.google.api.ads.admanager.axis.v202111.Network)1 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202111.NetworkServiceInterface)1 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)1