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());
}
}
Aggregations