Search in sources :

Example 1 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.v202108.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationPage) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationServiceInterface)

Example 2 with LineItemCreativeAssociationPage

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

the class UpdateLicas method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param lineItemId the line item ID of the LICA.
 * @param creativeId the master or creative set ID of the LICA. For creative sets, set the master
 *     creative ID.
 * @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, long creativeId) throws RemoteException {
    // Get the LineItemCreativeAssociationService.
    LineItemCreativeAssociationServiceInterface licaService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
    // Create a statement to select a single LICA for a line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("lineItemId = :lineItemId AND creativeId = :creativeId").orderBy("lineItemId ASC, creativeId ASC").limit(1).withBindVariableValue("lineItemId", lineItemId).withBindVariableValue("creativeId", creativeId);
    // Get the LICA.
    LineItemCreativeAssociationPage page = licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
    LineItemCreativeAssociation lica = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the destination URL.
    lica.setDestinationUrl("http://news.google.com?newTrackingParameter");
    // Update the LICA on the server.
    LineItemCreativeAssociation[] licas = licaService.updateLineItemCreativeAssociations(new LineItemCreativeAssociation[] { lica });
    for (LineItemCreativeAssociation updatedLica : licas) {
        System.out.printf("LICA with line item ID %d and creative ID %d was updated.%n", updatedLica.getLineItemId(), updatedLica.getCreativeId());
    }
}
Also used : LineItemCreativeAssociation(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationPage) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationServiceInterface)

Example 3 with LineItemCreativeAssociationPage

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

the class DeactivateLicas method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param lineItemId the ID of the line item to deactivate LICAs for.
 * @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 {
    // Get the LineItemCreativeAssociationService.
    LineItemCreativeAssociationServiceInterface licaService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
    // Create a statement to select all LICAs for a line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE lineItemId = :lineItemId").orderBy("lineItemId ASC, creativeId ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("lineItemId", lineItemId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get LICAs by statement.
        LineItemCreativeAssociationPage page = licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            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 will be deactivated.%n", i++, lica.getLineItemId(), lica.getCreativeSetId());
                } else {
                    System.out.printf("%d) LICA with line item ID %d and creative ID %d will be deactivated.%n", i++, lica.getLineItemId(), lica.getCreativeId());
                }
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of LICAs to be deactivated: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        DeactivateLineItemCreativeAssociations action = new DeactivateLineItemCreativeAssociations();
        // Perform action.
        UpdateResult result = licaService.performLineItemCreativeAssociationAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of LICAs deactivated: %d%n", result.getNumChanges());
        } else {
            System.out.println("No LICAs were deactivated.");
        }
    }
}
Also used : LineItemCreativeAssociation(com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociationPage) DeactivateLineItemCreativeAssociations(com.google.api.ads.admanager.axis.v202111.DeactivateLineItemCreativeAssociations) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociationServiceInterface) UpdateResult(com.google.api.ads.admanager.axis.v202111.UpdateResult)

Example 4 with LineItemCreativeAssociationPage

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

the class UpdateLicas method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param lineItemId the line item ID of the LICA.
 * @param creativeId the master or creative set ID of the LICA. For creative sets, set the master
 *     creative ID.
 * @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, long creativeId) throws RemoteException {
    // Get the LineItemCreativeAssociationService.
    LineItemCreativeAssociationServiceInterface licaService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
    // Create a statement to select a single LICA for a line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("lineItemId = :lineItemId AND creativeId = :creativeId").orderBy("lineItemId ASC, creativeId ASC").limit(1).withBindVariableValue("lineItemId", lineItemId).withBindVariableValue("creativeId", creativeId);
    // Get the LICA.
    LineItemCreativeAssociationPage page = licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
    LineItemCreativeAssociation lica = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the destination URL.
    lica.setDestinationUrl("http://news.google.com?newTrackingParameter");
    // Update the LICA on the server.
    LineItemCreativeAssociation[] licas = licaService.updateLineItemCreativeAssociations(new LineItemCreativeAssociation[] { lica });
    for (LineItemCreativeAssociation updatedLica : licas) {
        System.out.printf("LICA with line item ID %d and creative ID %d was updated.%n", updatedLica.getLineItemId(), updatedLica.getCreativeId());
    }
}
Also used : LineItemCreativeAssociation(com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociationPage) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202111.LineItemCreativeAssociationServiceInterface)

Example 5 with LineItemCreativeAssociationPage

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

the class DeactivateLicas method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param lineItemId the ID of the line item to deactivate LICAs for.
 * @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 {
    // Get the LineItemCreativeAssociationService.
    LineItemCreativeAssociationServiceInterface licaService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
    // Create a statement to select all LICAs for a line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE lineItemId = :lineItemId").orderBy("lineItemId ASC, creativeId ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("lineItemId", lineItemId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get LICAs by statement.
        LineItemCreativeAssociationPage page = licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            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 will be deactivated.%n", i++, lica.getLineItemId(), lica.getCreativeSetId());
                } else {
                    System.out.printf("%d) LICA with line item ID %d and creative ID %d will be deactivated.%n", i++, lica.getLineItemId(), lica.getCreativeId());
                }
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of LICAs to be deactivated: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        DeactivateLineItemCreativeAssociations action = new DeactivateLineItemCreativeAssociations();
        // Perform action.
        UpdateResult result = licaService.performLineItemCreativeAssociationAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of LICAs deactivated: %d%n", result.getNumChanges());
        } else {
            System.out.println("No LICAs were deactivated.");
        }
    }
}
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) DeactivateLineItemCreativeAssociations(com.google.api.ads.admanager.axis.v202205.DeactivateLineItemCreativeAssociations) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationServiceInterface) UpdateResult(com.google.api.ads.admanager.axis.v202205.UpdateResult)

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