Search in sources :

Example 16 with LineItemCreativeAssociationPage

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);
}
Also used : LineItemCreativeAssociation(com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationPage) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationServiceInterface)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)4 LineItemCreativeAssociation (com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociation)4 LineItemCreativeAssociationPage (com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationPage)4 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationServiceInterface)4 LineItemCreativeAssociation (com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociation)4 LineItemCreativeAssociationPage (com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociationPage)4 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociationServiceInterface)4 LineItemCreativeAssociation (com.google.api.ads.admanager.axis.v202202.LineItemCreativeAssociation)4 LineItemCreativeAssociationPage (com.google.api.ads.admanager.axis.v202202.LineItemCreativeAssociationPage)4 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202202.LineItemCreativeAssociationServiceInterface)4 LineItemCreativeAssociation (com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociation)4 LineItemCreativeAssociationPage (com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationPage)4 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationServiceInterface)4 DeactivateLineItemCreativeAssociations (com.google.api.ads.admanager.axis.v202108.DeactivateLineItemCreativeAssociations)1 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1 DeactivateLineItemCreativeAssociations (com.google.api.ads.admanager.axis.v202111.DeactivateLineItemCreativeAssociations)1 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)1