Search in sources :

Example 6 with Statement

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

the class UpdateActivityGroups method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param activityGroupId the ID of the activity group to update.
 * @param advertiserCompanyId the ID of the company to associate with the activity group.
 * @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 activityGroupId, long advertiserCompanyId) throws RemoteException {
    // Get the ActivityGroupService.
    ActivityGroupServiceInterface activityGroupService = adManagerServices.get(session, ActivityGroupServiceInterface.class);
    // Create a statement to only select a single activity group by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", activityGroupId);
    // Get the activity group.
    ActivityGroupPage page = activityGroupService.getActivityGroupsByStatement(statementBuilder.toStatement());
    ActivityGroup activityGroup = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the companies.
    activityGroup.setCompanyIds(Longs.concat(activityGroup.getCompanyIds(), new long[] { advertiserCompanyId }));
    // Update the activity group on the server.
    ActivityGroup[] activityGroups = activityGroupService.updateActivityGroups(new ActivityGroup[] { activityGroup });
    for (ActivityGroup updatedActivityGroup : activityGroups) {
        System.out.printf("Activity group with ID %d and name '%s' was updated.%n", updatedActivityGroup.getId(), updatedActivityGroup.getName());
    }
}
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 7 with Statement

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

the class StatementBuilder method toStatement.

/**
 * Gets the {@link Statement} representing the state of this statement builder.
 *
 * @return the {@link Statement}
 */
public Statement toStatement() {
    Statement statement = new Statement();
    statement.setQuery(queryBuilder.buildQuery());
    statement.getValues().addAll(Maps.toList(queryBuilder.getBindVariableMap(), StringValueMapEntry.class));
    return statement;
}
Also used : Statement(com.google.api.ads.admanager.jaxws.v202111.Statement) StringValueMapEntry(com.google.api.ads.admanager.jaxws.v202111.StringValueMapEntry)

Example 8 with Statement

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

the class StatementBuilder method toStatement.

/**
 * Gets the {@link Statement} representing the state of this statement builder.
 *
 * @return the {@link Statement}
 */
public Statement toStatement() {
    Statement statement = new Statement();
    statement.setQuery(queryBuilder.buildQuery());
    statement.setValues(Maps.toList(queryBuilder.getBindVariableMap(), String_ValueMapEntry.class).toArray(new String_ValueMapEntry[] {}));
    return statement;
}
Also used : String_ValueMapEntry(com.google.api.ads.admanager.axis.v202105.String_ValueMapEntry) Statement(com.google.api.ads.admanager.axis.v202105.Statement)

Example 9 with Statement

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

the class StatementBuilder method toStatement.

/**
 * Gets the {@link Statement} representing the state of this statement builder.
 *
 * @return the {@link Statement}
 */
public Statement toStatement() {
    Statement statement = new Statement();
    statement.setQuery(queryBuilder.buildQuery());
    statement.setValues(Maps.toList(queryBuilder.getBindVariableMap(), String_ValueMapEntry.class).toArray(new String_ValueMapEntry[] {}));
    return statement;
}
Also used : String_ValueMapEntry(com.google.api.ads.admanager.axis.v202111.String_ValueMapEntry) Statement(com.google.api.ads.admanager.axis.v202111.Statement)

Example 10 with Statement

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

the class StatementBuilder method toStatement.

/**
 * Gets the {@link Statement} representing the state of this statement builder.
 *
 * @return the {@link Statement}
 */
public Statement toStatement() {
    Statement statement = new Statement();
    statement.setQuery(queryBuilder.buildQuery());
    statement.setValues(Maps.toList(queryBuilder.getBindVariableMap(), String_ValueMapEntry.class).toArray(new String_ValueMapEntry[] {}));
    return statement;
}
Also used : String_ValueMapEntry(com.google.api.ads.admanager.axis.v202202.String_ValueMapEntry) Statement(com.google.api.ads.admanager.axis.v202202.Statement)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)119 Test (org.junit.Test)61 UpdateResult (com.google.api.ads.admanager.axis.v202202.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 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202202.CustomTargetingServiceInterface)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202202.InventoryServiceInterface)8 AdUnit (com.google.api.ads.admanager.axis.v202202.AdUnit)7 AdUnitPage (com.google.api.ads.admanager.axis.v202202.AdUnitPage)7 LineItem (com.google.api.ads.admanager.axis.v202202.LineItem)6 LineItemPage (com.google.api.ads.admanager.axis.v202202.LineItemPage)6 LineItemServiceInterface (com.google.api.ads.admanager.axis.v202202.LineItemServiceInterface)6 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202202.LineItemCreativeAssociationServiceInterface)5 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface)5 ResultSet (com.google.api.ads.admanager.axis.v202202.ResultSet)5 CustomTargetingValue (com.google.api.ads.admanager.axis.v202202.CustomTargetingValue)4 CustomTargetingValuePage (com.google.api.ads.admanager.axis.v202202.CustomTargetingValuePage)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202202.String_ValueMapEntry)4