Examples of InventoryServiceInterface


Examples of com.google.api.ads.dfp.axis.v201208.InventoryServiceInterface

*/
public class GetMobileAdUnitSizes {

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Create a statement to select ad unit sizes available for the mobile
    // platform.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("targetPlatform = :targetPlatform")
        .withBindVariableValue("targetPlatform", TargetPlatform.MOBILE.toString());

    // 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("%s) Web ad unit size of dimensions %s was found.\n", i,
View Full Code Here

Examples of com.google.api.ads.dfp.axis.v201211.InventoryServiceInterface

public class CreateAdUnits {

  public static void runExample(DfpServices dfpServices, DfpSession session, String parentId)
      throws Exception {
    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Create ad unit size.
    Size size = new Size();
    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);

    AdUnitSize adUnitSize = new AdUnitSize();
    adUnitSize.setSize(size);
    adUnitSize.setEnvironmentType(EnvironmentType.BROWSER);

    // Create a web ad unit.
    AdUnit webAdUnit = new AdUnit();
    webAdUnit.setName("Web_ad_unit_" + new Random().nextLong());
    webAdUnit.setDescription(webAdUnit.getName());
    webAdUnit.setTargetPlatform(TargetPlatform.WEB);
    webAdUnit.setParentId(parentId);
    webAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    webAdUnit.setAdUnitSizes(new AdUnitSize[]{adUnitSize});

    // Create a mobile ad unit.
    AdUnit mobileAdUnit = new AdUnit();
    mobileAdUnit.setName("Mobile_ad_unit_" + new Random().nextLong());
    mobileAdUnit.setDescription(webAdUnit.getName());
    mobileAdUnit.setTargetPlatform(TargetPlatform.MOBILE);
    mobileAdUnit.setParentId(parentId);
    mobileAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    mobileAdUnit.setMobilePlatform(MobilePlatform.APPLICATION);
    mobileAdUnit.setAdUnitSizes(new AdUnitSize[]{adUnitSize});

    // Create the ad units on the server.
    AdUnit[] adUnits = inventoryService.createAdUnits(new AdUnit[] {webAdUnit, mobileAdUnit});

    for (AdUnit adUnit : adUnits) {
      System.out.printf(
          "An ad unit with ID \"%s\", name \"%s\", and target platform \"%s\" was created.\n",
          adUnit.getId(), adUnit.getName(), adUnit.getTargetPlatform());
View Full Code Here

Examples of com.google.api.ads.dfp.axis.v201302.InventoryServiceInterface

public class CreateAdUnits {

  public static void runExample(DfpServices dfpServices, DfpSession session)
      throws Exception {
    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Get the NetworkService.
    NetworkServiceInterface networkService =
        dfpServices.get(session, NetworkServiceInterface.class);

    // Set the parent ad unit's ID for all ad units to be created under.
    String parentAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();

    // Create a 300x250 web ad unit size.
    Size webSize = new Size();
    webSize.setWidth(300);
    webSize.setHeight(250);
    webSize.setIsAspectRatio(false);

    AdUnitSize webAdUnitSize = new AdUnitSize();
    webAdUnitSize.setSize(webSize);
    webAdUnitSize.setEnvironmentType(EnvironmentType.BROWSER);

    // Create a 640x360v video ad unit size with a companion.
    Size videoSize = new Size();
    videoSize.setWidth(640);
    videoSize.setHeight(360);
    videoSize.setIsAspectRatio(false);

    AdUnitSize videoAdUnitSize = new AdUnitSize();
    videoAdUnitSize.setSize(videoSize);
    videoAdUnitSize.setCompanions(new AdUnitSize[] {webAdUnitSize});
    videoAdUnitSize.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);

    // Create a web ad unit.
    AdUnit webAdUnit = new AdUnit();
    webAdUnit.setName("web_ad_unit_" + new Random().nextInt(Integer.MAX_VALUE));
    webAdUnit.setDescription(webAdUnit.getName());
    webAdUnit.setTargetPlatform(TargetPlatform.WEB);
    webAdUnit.setParentId(parentAdUnitId);
    webAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    webAdUnit.setAdUnitSizes(new AdUnitSize[]{webAdUnitSize});

    // Create a video ad unit.
    AdUnit videoAdUnit = new AdUnit();
    videoAdUnit.setName("video_ad_unit_" + new Random().nextInt(Integer.MAX_VALUE));
    videoAdUnit.setDescription(videoAdUnit.getName());
    videoAdUnit.setTargetPlatform(TargetPlatform.WEB);
    videoAdUnit.setParentId(parentAdUnitId);
    videoAdUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
    videoAdUnit.setAdUnitSizes(new AdUnitSize[]{videoAdUnitSize});

    // Create the ad units on the server.
    AdUnit[] adUnits = inventoryService.createAdUnits(new AdUnit[] {webAdUnit, videoAdUnit});

    for (AdUnit adUnit : adUnits) {
      System.out.printf("An ad unit with ID \"%s\", name \"%s\" was created.\n", adUnit.getId(),
          adUnit.getName());
    }
View Full Code Here

Examples of com.google.api.ads.dfp.axis.v201306.InventoryServiceInterface

  public static List<AdUnit> getAllAdUnits(DfpServices dfpServices, DfpSession session)
      throws Exception {
    List<AdUnit> adUnits = Lists.newArrayList();

    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Create a statement to select all ad units.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get ad units by statement.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        Collections.addAll(adUnits, page.getResults());
      }
View Full Code Here

Examples of com.google.api.ads.dfp.axis.v201308.InventoryServiceInterface

  private static final String PLACEMENT_ID = "INSERT_PLACEMENT_ID_HERE";

  public static void runExample(DfpServices dfpServices, DfpSession session,
      String adUnitId, long placementId) throws Exception {
    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Create a statement to select ad units.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("id = :id")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("id", adUnitId);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get ad units by statement.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (AdUnit adUnit : page.getResults()) {
          System.out.printf(
              "%d) Ad unit with ID \"%s\" and name \"%s\" will be added to placement.\n", i++,
              adUnit.getId(), adUnit.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of ad units to be added to placement: %d\n", totalResultSetSize);

    if (totalResultSetSize > 0) {
      // Remove limit and offset from statement.
      statementBuilder.removeLimitAndOffset();

      // Create action.
      com.google.api.ads.dfp.axis.v201308.AssignAdUnitsToPlacement action =
          new com.google.api.ads.dfp.axis.v201308.AssignAdUnitsToPlacement();
      action.setPlacementId(placementId);

      // Perform action.
      UpdateResult result =
          inventoryService.performAdUnitAction(action, statementBuilder.toStatement());

      if (result != null && result.getNumChanges() > 0) {
        System.out.printf(
            "Number of ad units to be added to placement: %d\n", result.getNumChanges());
      } else {
View Full Code Here

Examples of com.google.api.ads.dfp.axis.v201311.InventoryServiceInterface

  public static List<AdUnit> getAllAdUnits(DfpServices dfpServices, DfpSession session)
      throws Exception {
    List<AdUnit> adUnits = Lists.newArrayList();

    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        dfpServices.get(session, InventoryServiceInterface.class);

    // Create a statement to select all ad units.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get ad units by statement.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        Collections.addAll(adUnits, page.getResults());
      }
View Full Code Here

Examples of com.google.api.ads.dfp.v201208.InventoryServiceInterface

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the InventoryService.
      InventoryServiceInterface inventoryService =
          user.getService(DfpService.V201208.INVENTORY_SERVICE);

      // Create a statement to get all ad units.
      Statement filterStatement = new Statement("LIMIT 500", null);

      // Get ad units by statement.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(filterStatement);

      if (page.getResults() != null) {
        // Update each local ad unit object by enabling AdSense.
        for (AdUnit adUnit : page.getResults()) {
          adUnit.getInheritedAdSenseSettings().getValue().setAdSenseEnabled(true);
        }

        // Update the ad units on the server.
        AdUnit[] updatedAdUnits = inventoryService.updateAdUnits(page.getResults());

        if (updatedAdUnits != null) {
          for (AdUnit adUnit : updatedAdUnits) {
            System.out.println("Ad unit with ID \"" + adUnit.getId() + "\", name \""
                + adUnit.getName() + "\", and is AdSense enabled \""
View Full Code Here

Examples of com.google.api.ads.dfp.v201208.InventoryServiceInterface

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the InventoryService.
      InventoryServiceInterface inventoryService =
          user.getService(DfpService.V201208.INVENTORY_SERVICE);

      // Get the NetworkService.
      NetworkServiceInterface networkService =
          user.getService(DfpService.V201208.NETWORK_SERVICE);

      // Get the effective root ad unit ID of the network.
      String effectiveRootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();

      // Create a statement to select the children of the effective root ad
      // unit.
      Statement filterStatement = new StatementBuilder("WHERE parentId = :id LIMIT 500")
          .putValue("id", effectiveRootAdUnitId).toStatement();

      // Get ad units by statement.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(filterStatement);

      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (AdUnit adUnit : page.getResults()) {
          System.out.println(i + ") Ad unit with ID \"" + adUnit.getId()
View Full Code Here

Examples of com.google.api.ads.dfp.v201208.InventoryServiceInterface

      throws ServiceException, RemoteException {
    // Create list to hold all ad units.
    List<AdUnit> adUnits = new ArrayList<AdUnit>();

    // Get InventoryService.
    InventoryServiceInterface inventoryService =
        user.getService(DfpService.V201208.INVENTORY_SERVICE);

    // Sets defaults for page and filterStatement.
    AdUnitPage page = new AdUnitPage();
    Statement filterStatement = new Statement();
    int offset = 0;

    do {
      // Create a statement to get all ad units.
      filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

      // Get ad units by statement.
      page = inventoryService.getAdUnitsByStatement(filterStatement);

      if (page.getResults() != null) {
        adUnits.addAll(Arrays.asList(page.getResults()));
      }
View Full Code Here

Examples of com.google.api.ads.dfp.v201208.InventoryServiceInterface

   * @throws RemoteException thrown if there was a problem retrieving ad units
   */
  private static AdUnit findRootAdUnit(DfpUser user)
      throws ServiceException, RemoteException {
    // Get InventoryService.
    InventoryServiceInterface inventoryService =
        user.getService(DfpService.V201208.INVENTORY_SERVICE);

    // Create a statement to only select the root ad unit.
    Statement filterStatement = new Statement("WHERE parentId IS NULL LIMIT 500", null);

    // Get ad units by statement.
    AdUnitPage page = inventoryService.getAdUnitsByStatement(filterStatement);

    if (page.getResults() != null) {
      return page.getResults()[0];
    }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.