Search in sources :

Example 16 with ActivityGroup

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

the class CreateActivityGroups method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param advertiserCompanyId the ID of the company for 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 advertiserCompanyId) throws RemoteException {
    // Get the ActivityGroupService.
    ActivityGroupServiceInterface activityGroupService = adManagerServices.get(session, ActivityGroupServiceInterface.class);
    // Create a short-term activity group.
    ActivityGroup shortTermActivityGroup = new ActivityGroup();
    shortTermActivityGroup.setName("Short-term activity group #" + new Random().nextInt(Integer.MAX_VALUE));
    shortTermActivityGroup.setCompanyIds(new long[] { advertiserCompanyId });
    shortTermActivityGroup.setClicksLookback(1);
    shortTermActivityGroup.setImpressionsLookback(1);
    // Create a long-term activity group.
    ActivityGroup longTermActivityGroup = new ActivityGroup();
    longTermActivityGroup.setName("Long-term activity group #" + new Random().nextInt(Integer.MAX_VALUE));
    longTermActivityGroup.setCompanyIds(new long[] { advertiserCompanyId });
    longTermActivityGroup.setClicksLookback(30);
    longTermActivityGroup.setImpressionsLookback(30);
    // Create the activity groups on the server.
    ActivityGroup[] activityGroups = activityGroupService.createActivityGroups(new ActivityGroup[] { shortTermActivityGroup, longTermActivityGroup });
    for (ActivityGroup createdActivityGroup : activityGroups) {
        System.out.printf("An activity group with ID %d and name '%s' was created.%n", createdActivityGroup.getId(), createdActivityGroup.getName());
    }
}
Also used : Random(java.util.Random) ActivityGroupServiceInterface(com.google.api.ads.admanager.axis.v202205.ActivityGroupServiceInterface) ActivityGroup(com.google.api.ads.admanager.axis.v202205.ActivityGroup)

Aggregations

ActivityGroup (com.google.api.ads.admanager.axis.v202108.ActivityGroup)4 ActivityGroupServiceInterface (com.google.api.ads.admanager.axis.v202108.ActivityGroupServiceInterface)4 ActivityGroup (com.google.api.ads.admanager.axis.v202111.ActivityGroup)4 ActivityGroupServiceInterface (com.google.api.ads.admanager.axis.v202111.ActivityGroupServiceInterface)4 ActivityGroup (com.google.api.ads.admanager.axis.v202202.ActivityGroup)4 ActivityGroupServiceInterface (com.google.api.ads.admanager.axis.v202202.ActivityGroupServiceInterface)4 ActivityGroup (com.google.api.ads.admanager.axis.v202205.ActivityGroup)4 ActivityGroupServiceInterface (com.google.api.ads.admanager.axis.v202205.ActivityGroupServiceInterface)4 Random (java.util.Random)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 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)3 ActivityGroupPage (com.google.api.ads.admanager.axis.v202108.ActivityGroupPage)3 ActivityGroupPage (com.google.api.ads.admanager.axis.v202111.ActivityGroupPage)3 ActivityGroupPage (com.google.api.ads.admanager.axis.v202202.ActivityGroupPage)3 ActivityGroupPage (com.google.api.ads.admanager.axis.v202205.ActivityGroupPage)3