use of com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationPage in project googleads-java-lib by googleads.
the class GetLicasForLineItem method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param lineItemId the ID of the line item.
* @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 lineItemId) throws RemoteException {
LineItemCreativeAssociationServiceInterface lineItemCreativeAssociationService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
// Create a statement to select line item creative associations.
StatementBuilder statementBuilder = new StatementBuilder().where("lineItemId = :lineItemId").orderBy("lineItemId ASC, creativeId ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("lineItemId", lineItemId);
// Retrieve a small amount of line item creative associations at a time, paging through
// until all line item creative associations have been retrieved.
int totalResultSetSize = 0;
do {
LineItemCreativeAssociationPage page = lineItemCreativeAssociationService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
// Print out some information for each line item creative association.
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (LineItemCreativeAssociation lica : page.getResults()) {
if (lica.getCreativeSetId() != null) {
System.out.printf("%d) LICA with line item ID %d and creative set ID %d was found.%n", i++, lica.getLineItemId(), lica.getCreativeSetId());
} else {
System.out.printf("%d) LICA with line item ID %d and creative ID %d was found.%n", i++, lica.getLineItemId(), lica.getCreativeId());
}
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Aggregations