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

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


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


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

      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

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

      // Create an array to store local label objects.
      Label[] labels = new Label[5];

      for (int i = 0; i < 5; i++) {
        Label label = new Label();
        label.setName("Label #" + i);
        label.setTypes(new LabelType[] {LabelType.COMPETITIVE_EXCLUSION});
        labels[i] = label;
      }

      // Create the labels on the server.
      labels = labelService.createLabels(labels);

      if (labels != null) {
        for (Label label : labels) {
          List<String> labelTypes = new ArrayList<String>();
          for (LabelType labelType : label.getTypes()) {
            labelTypes.add(labelType.toString());
          }
          System.out.println("A label with ID \"" + label.getId()
              + "\", name \"" + label.getName()
              + "\", and types {" + StringUtils.join(labelTypes, ",") + "} was created.");
        }
      } else {
        System.out.println("No labels created.");
      }
View Full Code Here

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

      // Get the LabelService.
      LabelServiceInterface labelService = user.getService(DfpService.V201208.LABEL_SERVICE);

      // Create an array to store local label objects.
      Label[] labels = new Label[5];

      for (int i = 0; i < 5; i++) {
        Label label = new Label();
        label.setName("Label #" + i);
        label.setTypes(new LabelType[] {LabelType.COMPETITIVE_EXCLUSION});
        labels[i] = label;
      }

      // Create the labels on the server.
      labels = labelService.createLabels(labels);

      if (labels != null) {
        for (Label label : labels) {
          List<String> labelTypes = new ArrayList<String>();
          for (LabelType labelType : label.getTypes()) {
View Full Code Here

      Statement filterStatement =
          new StatementBuilder("WHERE lineItemId = :lineItemId LIMIT 500")
              .putValue("lineItemId", lineItemId).toStatement();

      // Get LICAs by statement.
      LineItemCreativeAssociationPage page =
         licaService.getLineItemCreativeAssociationsByStatement(filterStatement);

      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (LineItemCreativeAssociation lica : page.getResults()) {
          System.out.println(i + ") LICA with line item ID \"" + lica.getLineItemId()
              + "\", creative ID \"" + lica.getCreativeId()
              + "\", and status \"" + lica.getStatus()
              + "\" was found.");
          i++;
        }
      }

      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 LineItemCreativeAssociationService.
      LineItemCreativeAssociationServiceInterface licaService =
          user.getService(DfpService.V201208.LINEITEMCREATIVEASSOCIATION_SERVICE);

      // Set the line item to get LICAs by.
      Long lineItemId = Long.parseLong("INSERT_LINE_ITEM_ID_HERE");

      // Create a statement to only select LICAs for the given lineItem ID.
      Statement filterStatement =
          new StatementBuilder("WHERE lineItemId = :lineItemId LIMIT 500")
              .putValue("lineItemId", lineItemId).toStatement();

      // Get LICAs by statement.
      LineItemCreativeAssociationPage page =
         licaService.getLineItemCreativeAssociationsByStatement(filterStatement);

      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (LineItemCreativeAssociation lica : page.getResults()) {
          System.out.println(i + ") LICA with line item ID \"" + lica.getLineItemId()
View Full Code Here

      // Set the ID of the order to get line items from.
      Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

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

      // Create a statement to only select line items from a given order.
      String filterText = "WHERE orderId = :orderId LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(filterText).putValue("orderId", orderId).toStatement();

      // Collect all line item custom field IDs for an order.
      Set<Long> customFieldIds = new HashSet<Long>();
      do {
        filterStatement.setQuery(filterText + " OFFSET " + offset);

        // Get line items by statement.
        page = lineItemService.getLineItemsByStatement(filterStatement);

        // Get custom field IDs from the line items of an order.
        if (page.getResults() != null) {
          for (LineItem lineItem : page.getResults()) {
            if (lineItem.getCustomFieldValues() != null) {
              for (BaseCustomFieldValue customFieldValue : lineItem.getCustomFieldValues()) {
                customFieldIds.add(customFieldValue.getCustomFieldId());
              }
            }
          }
        }

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

      // Get the ReportService.
      ReportServiceInterface reportService = user.getService(DfpService.V201208.REPORT_SERVICE);

      // Create statement to filter for an order.
View Full Code Here

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

TOP

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

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.