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

Examples of com.google.api.ads.dfp.v201211.ApproveAndOverbookOrders


      } else {
        System.out.println("No keys were created.");
      }

      // Create custom targeting value for the predefined gender key.
      CustomTargetingValue genderMaleValue = new CustomTargetingValue();
      genderMaleValue.setCustomTargetingKeyId(keys[0].getId());
      genderMaleValue.setDisplayName("male");
      // Name is set to 1 so that the actual name can be hidden from website
      // users.
      genderMaleValue.setName("1");
      genderMaleValue.setMatchType(CustomTargetingValueMatchType.EXACT);

      CustomTargetingValue genderFemaleValue = new CustomTargetingValue();
      genderFemaleValue.setCustomTargetingKeyId(keys[0].getId());
      genderFemaleValue.setDisplayName("female");
      // Name is set to 2 so that the actual name can be hidden from website
      // users.
      genderFemaleValue.setName("2");
      genderFemaleValue.setMatchType(CustomTargetingValueMatchType.EXACT);

      // Create custom targeting value for the predefined genre key.
      CustomTargetingValue genreComedyValue = new CustomTargetingValue();
      genreComedyValue.setCustomTargetingKeyId(keys[1].getId());
      genreComedyValue.setDisplayName("comedy");
      genreComedyValue.setName("comedy");
      genreComedyValue.setMatchType(CustomTargetingValueMatchType.EXACT);

      CustomTargetingValue genreDramaValue = new CustomTargetingValue();
      genreDramaValue.setCustomTargetingKeyId(keys[1].getId());
      genreDramaValue.setDisplayName("drama");
      genreDramaValue.setName("drama");
      genreDramaValue.setMatchType(CustomTargetingValueMatchType.EXACT);

      // Create custom targeting value for the free-form age key. These are
      // values that would be suggested in the UI or can be used when targeting
      // with a {@link FreeFormCustomCriteria}.
      CustomTargetingValue carModelHondaCivicValue = new CustomTargetingValue();
      carModelHondaCivicValue.setCustomTargetingKeyId(keys[2].getId());
      carModelHondaCivicValue.setDisplayName("honda civic");
      carModelHondaCivicValue.setName("honda civic");
      // Setting match type to exact will match exactly "honda civic".
      carModelHondaCivicValue.setMatchType(CustomTargetingValueMatchType.EXACT);

      // Create the custom targeting values on the server.
      CustomTargetingValue[] returnValues =
          customTargetingService.createCustomTargetingValues(new CustomTargetingValue[] {
              genderMaleValue, genderFemaleValue, genreComedyValue, genreDramaValue,
View Full Code Here


          " and name = :category LIMIT 1")
          .putValue("contentBrowseCustomTargetingKeyId", contentBrowseCustomTargetingKeyId)
          .putValue("category", "comedy").toStatement();

      // Get categories matching the filter statement.
      CustomTargetingValuePage customTargetingValuePage =
          customTargetingService.getCustomTargetingValuesByStatement(categoryFilterStatement);

      // Get the custom targeting value ID for the comedy category.
      long categoryCustomTargetingValueId = customTargetingValuePage.getResults()[0].getId();

      // Set defaults for page and filterStatement.
      ContentPage page = new ContentPage();
      Statement filterStatement = new Statement();
      int offset = 0;
View Full Code Here

      String statementText = "WHERE customTargetingKeyId = :customTargetingKeyId";
      StatementBuilder statementBuilder = new StatementBuilder("")
          .putValue("customTargetingKeyId", customTargetingKeyId);

      // Set defaults for page and offset.
      CustomTargetingValuePage page = new CustomTargetingValuePage();
      int offset = 0;
      List<Long> customTargetingValueIds = new ArrayList<Long>();

      do {
        // Create a statement to page through custom targeting values.
        statementBuilder.setQuery(statementText + " LIMIT 500 OFFSET " + offset);

        // Get custom targeting values by statement.
        page = customTargetingService.getCustomTargetingValuesByStatement(
            statementBuilder.toStatement());

        if (page.getResults() != null) {
          for (CustomTargetingValue customTargetingValue : page.getResults()) {
            customTargetingValueIds.add(customTargetingValue.getId());
          }
        }

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

      System.out.println(
          "Number of custom targeting values to be deleted: " + customTargetingValueIds.size());

      if (customTargetingValueIds.size() > 0) {
View Full Code Here

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

      // Get custom targeting values by statement.
      CustomTargetingValuePage page =
          customTargetingService.getCustomTargetingValuesByStatement(filterStatement);

      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (CustomTargetingValue customTargetingValue : page.getResults()) {
          System.out.println(i + ") Custom targeting value with ID \""
              + customTargetingValue.getId() + "\", name \"" + customTargetingValue.getName()
              + "\", and display name \"" + customTargetingValue.getDisplayName()
              + "\" was found.");
          i++;
        }
      }

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

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

      // Get custom targeting values by statement.
      CustomTargetingValuePage page =
          customTargetingService.getCustomTargetingValuesByStatement(filterStatement);

      if (page.getResults() != null) {
        CustomTargetingValue[] customTargetingValues = page.getResults();

        // Update each local custom targeting value object by changing its
        // display name.
        for (CustomTargetingValue customTargetingValue : customTargetingValues) {
          if (customTargetingValue.getDisplayName() == null) {
View Full Code Here

                + "\", name \"" + key.getName() + "\", display name \"" + key.getDisplayName()
                + "\", and type \"" + key.getType() + "\" was found.");


            // Sets defaults for page and filter.
            CustomTargetingValuePage valuePage = new CustomTargetingValuePage();
            Statement valueFilterStatement = new Statement();
            int valueOffset = 0;

            do {
              // Create a statement to get all custom targeting values for a
              // custom targeting key (required) by its ID.
              valueFilterStatement.setQuery("WHERE customTargetingKeyId = " + key.getId()
                  + " LIMIT 500 OFFSET " + valueOffset);

              // Get custom targeting values by statement.
              valuePage =
                  customTargetingService.getCustomTargetingValuesByStatement(valueFilterStatement);

              if (valuePage.getResults() != null) {
                int j = valuePage.getStartIndex();
                for (CustomTargetingValue value : valuePage.getResults()) {
                  System.out.println("\t" + j + ") Custom targeting value with ID \""
                      + value.getId() + "\", name \"" + value.getName() + "\", and display name \""
                      + value.getDisplayName() + "\" was found.");
                  j++;
                }
              }
              valueOffset += 500;
            } while (valuePage.getResults() != null && valuePage.getResults().length == 500);

            i++;
          }
        }
        keyOffset += 500;
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

   * @param date the DFP {@code Date} object to convert to a Java {@code Date}
   * @param timeZoneId the timezone of the date
   * @return the DFP {@code Date} object as a Java {@code Date} in the timezone
   */
  public static java.util.Date toDate(Date date, String timeZoneId) {
    return DateTimeUtils.toDate(new DateTime(date, 0, 0, 0, timeZoneId));
  }
View Full Code Here

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

    DateTime dfpDateTime = new DateTime();
    dfpDateTime.setDate(DateUtils.fromDate(date));
    dfpDateTime.setHour(calendar.get(Calendar.HOUR_OF_DAY));
    dfpDateTime.setMinute(calendar.get(Calendar.MINUTE));
    dfpDateTime.setSecond(calendar.get(Calendar.SECOND));

    return dfpDateTime;
  }
View Full Code Here

   * @param timeZoneId the timezone of the publisher
   * @return a {@code DateTime} object representing the present date in the
   *     publisher's timezone
   */
  public static DateTime today(String timeZoneId) {
    DateTime dateTime =
        fromDate(Calendar.getInstance(TimeZone.getTimeZone(timeZoneId)).getTime());
    dateTime.setHour(0);
    dateTime.setMinute(0);
    dateTime.setSecond(0);
    return dateTime;
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201211.ApproveAndOverbookOrders

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.