Search in sources :

Example 46 with Statement

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

the class UpdateCustomTargetingValues method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param customTargetingValueId the ID of the custom targeting value 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 customTargetingValueId) throws RemoteException {
    // Get the CustomTargetingService.
    CustomTargetingServiceInterface customTargetingService = adManagerServices.get(session, CustomTargetingServiceInterface.class);
    // Create a statement to get custom targeting values.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", customTargetingValueId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get custom targeting values by statement.
        CustomTargetingValuePage page = customTargetingService.getCustomTargetingValuesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            CustomTargetingValue[] customTargetingValues = page.getResults();
            // name.
            for (CustomTargetingValue customTargetingValue : customTargetingValues) {
                if (customTargetingValue.getDisplayName() == null) {
                    customTargetingValue.setDisplayName(customTargetingValue.getName());
                }
                customTargetingValue.setDisplayName(customTargetingValue.getDisplayName() + " (Deprecated)");
            }
            // Update the custom targeting values on the server.
            customTargetingValues = customTargetingService.updateCustomTargetingValues(customTargetingValues);
            for (CustomTargetingValue updatedCustomTargetingValue : customTargetingValues) {
                System.out.printf("Custom targeting value with ID %d, name '%s', and display name " + "'%s' was updated.%n", updatedCustomTargetingValue.getId(), updatedCustomTargetingValue.getName(), updatedCustomTargetingValue.getDisplayName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
}
Also used : CustomTargetingValue(com.google.api.ads.admanager.axis.v202111.CustomTargetingValue) CustomTargetingServiceInterface(com.google.api.ads.admanager.axis.v202111.CustomTargetingServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) CustomTargetingValuePage(com.google.api.ads.admanager.axis.v202111.CustomTargetingValuePage)

Example 47 with Statement

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

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

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

Example 49 with Statement

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

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

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

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)119 Test (org.junit.Test)77 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)18 Statement (com.google.api.ads.admanager.axis.v202105.Statement)16 Statement (com.google.api.ads.admanager.axis.v202108.Statement)16 Statement (com.google.api.ads.admanager.axis.v202111.Statement)16 Statement (com.google.api.ads.admanager.axis.v202202.Statement)16 Statement (com.google.api.ads.admanager.axis.v202205.Statement)16 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202111.CustomTargetingServiceInterface)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface)8 AdUnit (com.google.api.ads.admanager.axis.v202111.AdUnit)7 AdUnitPage (com.google.api.ads.admanager.axis.v202111.AdUnitPage)7 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)7 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)7 ArrayList (java.util.ArrayList)6 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)5 Statement (org.neo4j.driver.v1.Statement)5 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202105.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202108.String_ValueMapEntry)4 LineItem (com.google.api.ads.admanager.axis.v202111.LineItem)4