Search in sources :

Example 16 with AdUnitSize

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

the class GetAllAdUnitSizes method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @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) throws RemoteException {
    // Get the InventoryService.
    InventoryServiceInterface inventoryService = adManagerServices.get(session, InventoryServiceInterface.class);
    // Create a statement to select all ad unit sizes.
    StatementBuilder statementBuilder = new StatementBuilder();
    // Get all ad unit sizes.
    AdUnitSize[] adUnitSizes = inventoryService.getAdUnitSizesByStatement(statementBuilder.toStatement());
    if (adUnitSizes != null) {
        for (int i = 0; i < adUnitSizes.length; i++) {
            AdUnitSize adUnitSize = adUnitSizes[i];
            System.out.printf("%d) Ad unit size of dimensions '%s' was found.%n", i, adUnitSize.getFullDisplayString());
        }
    } else {
        System.out.println("No ad unit sizes found.");
    }
}
Also used : AdUnitSize(com.google.api.ads.admanager.axis.v202205.AdUnitSize) InventoryServiceInterface(com.google.api.ads.admanager.axis.v202205.InventoryServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)

Aggregations

ArrayList (java.util.ArrayList)8 Random (java.util.Random)8 AdUnitSize (com.google.api.ads.admanager.axis.v202108.AdUnitSize)4 AdUnitSize (com.google.api.ads.admanager.axis.v202111.AdUnitSize)4 AdUnitSize (com.google.api.ads.admanager.axis.v202202.AdUnitSize)4 AdUnitSize (com.google.api.ads.admanager.axis.v202205.AdUnitSize)4 AdUnit (com.google.api.ads.admanager.axis.v202108.AdUnit)3 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202108.InventoryServiceInterface)3 Size (com.google.api.ads.admanager.axis.v202108.Size)3 AdUnit (com.google.api.ads.admanager.axis.v202111.AdUnit)3 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface)3 Size (com.google.api.ads.admanager.axis.v202111.Size)3 AdUnit (com.google.api.ads.admanager.axis.v202202.AdUnit)3 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202202.InventoryServiceInterface)3 Size (com.google.api.ads.admanager.axis.v202202.Size)3 AdUnit (com.google.api.ads.admanager.axis.v202205.AdUnit)3 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202205.InventoryServiceInterface)3 Size (com.google.api.ads.admanager.axis.v202205.Size)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)2 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)2