Search in sources :

Example 61 with NetworkServiceInterface

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

the class GetAllNetworks 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 NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Get all networks that you have access to with the current authentication
    // credentials.
    Network[] networks = networkService.getAllNetworks();
    int i = 0;
    for (Network network : networks) {
        System.out.printf("%d) Network with network code '%s' and display name '%s' was found.%n", i++, network.getNetworkCode(), network.getDisplayName());
    }
    System.out.printf("Number of networks found: %d%n", networks.length);
}
Also used : NetworkServiceInterface(com.google.api.ads.admanager.axis.v202205.NetworkServiceInterface) Network(com.google.api.ads.admanager.axis.v202205.Network)

Example 62 with NetworkServiceInterface

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

the class GetAdUnitHierarchy 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);
    // Get the NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Get the effective root ad unit.
    String rootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();
    // Create a statement to select only the root ad unit by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", rootAdUnitId);
    AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());
    AdUnit effectiveRootAdUnit = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Get all ad units.
    List<AdUnit> adUnits = getAllAdUnits(adManagerServices, session);
    buildAndDisplayAdUnitTree(effectiveRootAdUnit, adUnits);
}
Also used : NetworkServiceInterface(com.google.api.ads.admanager.axis.v202205.NetworkServiceInterface) AdUnitPage(com.google.api.ads.admanager.axis.v202205.AdUnitPage) AdUnit(com.google.api.ads.admanager.axis.v202205.AdUnit) InventoryServiceInterface(com.google.api.ads.admanager.axis.v202205.InventoryServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)

Aggregations

Random (java.util.Random)24 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202205.NetworkServiceInterface)17 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202108.NetworkServiceInterface)15 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202111.NetworkServiceInterface)15 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202202.NetworkServiceInterface)15 AdUnitTargeting (com.google.api.ads.admanager.axis.v202108.AdUnitTargeting)7 InventoryTargeting (com.google.api.ads.admanager.axis.v202108.InventoryTargeting)7 AdUnitTargeting (com.google.api.ads.admanager.axis.v202111.AdUnitTargeting)7 InventoryTargeting (com.google.api.ads.admanager.axis.v202111.InventoryTargeting)7 AdUnitTargeting (com.google.api.ads.admanager.axis.v202202.AdUnitTargeting)7 InventoryTargeting (com.google.api.ads.admanager.axis.v202202.InventoryTargeting)7 AdUnitTargeting (com.google.api.ads.admanager.axis.v202205.AdUnitTargeting)7 InventoryTargeting (com.google.api.ads.admanager.axis.v202205.InventoryTargeting)7 Targeting (com.google.api.ads.admanager.axis.v202108.Targeting)6 Targeting (com.google.api.ads.admanager.axis.v202202.Targeting)6 Network (com.google.api.ads.admanager.axis.v202205.Network)6 Targeting (com.google.api.ads.admanager.axis.v202205.Targeting)6 Size (com.google.api.ads.admanager.axis.v202108.Size)5 Size (com.google.api.ads.admanager.axis.v202202.Size)5 Size (com.google.api.ads.admanager.axis.v202205.Size)5