Package com.google.api.ads.dfp.axis.v201211

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


  @Test
  public void testToString_null() {
    assertEquals("", Pql.toString(new TextValue()));
    assertEquals("", Pql.toString(new BooleanValue()));
    assertEquals("", Pql.toString(new NumberValue()));
    assertEquals("", Pql.toString(new DateTimeValue()));   
  }
View Full Code Here


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

public class ArchiveAdUnits {

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

    // Create a statement to select ad units under the parent ad unit and the
    // parent ad unit.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("parentId = :parentId or id = :parentId")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("parentId", parentAdUnitId);

    // Default for total result set size.
    int totalResultSetSize = 0;
    List<String> adUnitIds = new ArrayList<String>();

    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(
              "%s) Ad unit with ID \"%s\" and name \"%s\" will be archived.\n", i,
              adUnit.getId(), adUnit.getName());
          adUnitIds.add(adUnit.getId());
          i++;
        }
      }

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

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

    if (!adUnitIds.isEmpty()) {
      // Remove limit and offset from statement.
      statementBuilder.removeLimitAndOffset();

      // Create action.
      com.google.api.ads.dfp.axis.v201211.ArchiveAdUnits action =
          new com.google.api.ads.dfp.axis.v201211.ArchiveAdUnits();

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

      if (result != null && result.getNumChanges() > 0) {
        System.out.println("Number of ad units archived: " + result.getNumChanges());
      } else {
        System.out.println("No ad units were archived.");
View Full Code Here

public class GetTopLevelAdUnits {

  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 children ad units to be fetched from.
    String parentAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();

    // Create a statement to select ad units under the parent ad unit.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("parentId = :parentId")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("parentId", parentAdUnitId);

    // 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()) {
View Full Code Here

  public static List<AdUnit> runExample(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()
        .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();
        int i = page.getStartIndex();
        for (AdUnit adUnit : page.getResults()) {
View Full Code Here

  static final String AD_UNIT_ID = "INSERT_AD_UNIT_ID_HERE";

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

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

    // Add the size 468x60 to the ad unit.
    List<AdUnitSize> adUnitSizes = Lists.<AdUnitSize>newArrayList(adUnit.getAdUnitSizes());

    Size size = new Size();
    size.setWidth(468);
    size.setHeight(60);

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

    adUnit.setAdUnitSizes(adUnitSizes.toArray(new AdUnitSize[] {}));

    // Update the ad units on the server.
    AdUnit[] adUnits = inventoryService.updateAdUnits(new AdUnit[] {adUnit});

    for (AdUnit updatedAdUnit : adUnits) {
      List<String> adUnitSizeStrings = Lists.newArrayList();
      for (AdUnitSize updatedAdUnitSize : updatedAdUnit.getAdUnitSizes()) {
        adUnitSizeStrings.add(String.format("{%s x %s}", updatedAdUnitSize.getSize().getWidth(),
View Full Code Here

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    List<AdUnit> adUnits = GetAllAdUnits.runExample(dfpServices, session);

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

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

    // Get the effective root ad unit.
    AdUnit effectiveRootAdUnit =
        inventoryService.getAdUnit(
            networkService.getCurrentNetwork().getEffectiveRootAdUnitId());

    buildAndDisplayAdUnitTree(effectiveRootAdUnit, adUnits);
  }
View Full Code Here

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

        .build();

    DfpServices dfpServices = new DfpServices();

    // 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 parentId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();

    runExample(dfpServices, session, parentId);
  }
View Full Code Here

        .build();

    DfpServices dfpServices = new DfpServices();

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

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

    runExample(dfpServices, session, parentAdUnitId);
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.axis.v201211.Date

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.