Package com.google.api.ads.dfp.v201208

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


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

      // Create local ad unit object.
      AdUnit adUnit = new AdUnit();
      adUnit.setName("Video_Ad_Unit");
      adUnit.setParentId(effectiveRootAdUnitId);
      adUnit.setDescription("Ad unit description.");
      adUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
      adUnit.setExplicitlyTargeted(true);
      adUnit.setTargetPlatform(TargetPlatform.WEB);

      // Create master ad unit size.
      AdUnitSize masterAdUnitSize = new AdUnitSize();
      masterAdUnitSize.setSize(new Size(400, 300, false));
      masterAdUnitSize.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);

      // Create companion sizes.
      AdUnitSize companionAdUnitSize1 = new AdUnitSize();
      companionAdUnitSize1.setSize(new Size(300, 250, false));
      companionAdUnitSize1.setEnvironmentType(EnvironmentType.BROWSER);

      AdUnitSize companionAdUnitSize2 = new AdUnitSize();
      companionAdUnitSize2.setSize(new Size(728, 90, false));
      companionAdUnitSize2.setEnvironmentType(EnvironmentType.BROWSER);

      // Add companions to master ad unit size.
      masterAdUnitSize.setCompanions(new AdUnitSize[] {companionAdUnitSize1, companionAdUnitSize2});

      // Set the size of possible creatives that can match this ad unit.
      adUnit.setAdUnitSizes(new AdUnitSize[] {masterAdUnitSize});

      // Create the ad unit on the server.
      adUnit = inventoryService.createAdUnit(adUnit);

      if (adUnit != null) {
        System.out.println("An ad unit with ID \"" + adUnit.getId()
            + "\" was created under parent with ID \"" + adUnit.getParentId()
            + "\".");
      } else {
        System.out.println("No ad units created.");
      }
    } catch (Exception e) {
View Full Code Here


      // Set the ID of the ad unit to get.
      String adUnitId = "INSERT_AD_UNIT_ID_HERE";

      // Get the ad unit.
      AdUnit adUnit = inventoryService.getAdUnit(adUnitId);

      if (adUnit != null) {
        System.out.println("Ad unit with ID \"" + adUnit.getId()
            + "\", name \"" + adUnit.getName()
            + "\", and status \"" + adUnit.getStatus() + "\" was found.");
      } else {
        System.out.println("No ad unit found for this ID.");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      // Find the root ad unit. rootAdUnit can also be set to child unit to
      // only build and display a portion of the tree.
      // i.e. AdUnit adUnit =
      //          inventoryService.getAdUnit("INSERT_AD_UNIT_HERE")
      AdUnit rootAdUnit = findRootAdUnit(user);

      if (rootAdUnit == null) {
        System.out.println("Could not build tree. No root ad unit found.");
      } else {
        buildAndDisplayAdUnitTree(rootAdUnit, allAdUnits);
View Full Code Here

      // 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

      // 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()
              + "\", name \"" + adUnit.getName()
              + "\", and status \"" + adUnit.getStatus() + "\" was found.");
          i++;
        }
      }

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

        System.out.println("Number of suggested ad units to be approved: "
            + page.getTotalResultSetSize());

        // Create action.
        ApproveSuggestedAdUnit action = new ApproveSuggestedAdUnit();

        // Perform action.
        SuggestedAdUnitUpdateResult result =
            suggestedAdUnitService.performSuggestedAdUnitAction(action, filterStatement);
View Full Code Here

      return (Value) value;
    } else if (value == null) {
      return new TextValue(null, null);
    } else {
      if (value instanceof Boolean) {
        return new BooleanValue(null, (Boolean) value);
      } else if (value instanceof Double) {
        return new NumberValue(null, value.toString());
      } else if (value instanceof String) {
        return new TextValue(null, (String) value);
      } else if (value instanceof Long) {
View Full Code Here

      // Get the CreativeTemplateService.
      CreativeTemplateServiceInterface creativeTemplateService =
          user.getService(DfpService.V201208.CREATIVE_TEMPLATE_SERVICE);

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

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

        // Get creative templates by statement.
        page = creativeTemplateService.getCreativeTemplatesByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (CreativeTemplate creativeTemplate : page.getResults()) {
            System.out.println(i + ") Creative template with ID \"" + creativeTemplate.getId()
                + "\", name \"" + creativeTemplate.getName()
                + "\", and type \"" + creativeTemplate.getType() + "\" was found.");
            i++;
          }
        }

        offset += 500;
      } while (offset < page.getTotalResultSetSize());

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

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

      // Get the CreativeTemplateService.
      CreativeTemplateServiceInterface creativeTemplateService =
          user.getService(DfpService.V201208.CREATIVE_TEMPLATE_SERVICE);

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

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

        // Get creative templates by statement.
        page = creativeTemplateService.getCreativeTemplatesByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (CreativeTemplate creativeTemplate : page.getResults()) {
            System.out.println(i + ") Creative template with ID \"" + creativeTemplate.getId()
View Full Code Here

   */
  public static Date fromDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    Date dfpDate = new Date();
    dfpDate.setYear(calendar.get(Calendar.YEAR));
    dfpDate.setMonth(calendar.get(Calendar.MONTH) + 1);
    dfpDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));

    return dfpDate;
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201208.AdUnit

Copyright © 2018 www.massapicom. 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.