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

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


    // Get the ContentService.
    ContentServiceInterface contentService =
        dfpServices.get(session, ContentServiceInterface.class);

    // Get the CustomTargetingService.
    CustomTargetingServiceInterface customTargetingService =
        dfpServices.get(session, CustomTargetingServiceInterface.class);

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

    // Get content browse custom targeting key ID.
    long contentBrowseCustomTargetingKeyId =
        networkService.getCurrentNetwork().getContentBrowseCustomTargetingKeyId();

    if (contentBrowseCustomTargetingKeyId == 0) {
      throw new RuntimeException("Your network does not have content categories enabled.");     
    }

    // Create a statement to select the categories matching the name comedy.
    Statement categoryFilterStatement = new StatementBuilder()
        .where("customTargetingKeyId = :contentBrowseCustomTargetingKeyId and name = :category")
        .limit(1)
        .withBindVariableValue(
            "contentBrowseCustomTargetingKeyId", contentBrowseCustomTargetingKeyId)
        .withBindVariableValue("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();

    // Create a statement to select all content.
View Full Code Here


*/
public class CreateCustomTargetingKeysAndValues {

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the CustomTargetingService.
    CustomTargetingServiceInterface customTargetingService =
        dfpServices.get(session, CustomTargetingServiceInterface.class);

    // Create predefined key.
    CustomTargetingKey genderKey = new CustomTargetingKey();
    genderKey.setDisplayName("gender");
    genderKey.setName("g" + new Random().nextInt(1000));
    genderKey.setType(CustomTargetingKeyType.PREDEFINED);

    // Create predefined key that may be used for content targeting.
    CustomTargetingKey genreKey = new CustomTargetingKey();
    genreKey.setDisplayName("genre");
    genreKey.setName("genre" + new Random().nextInt(1000));
    genreKey.setType(CustomTargetingKeyType.PREDEFINED);

    // Create free-form key.
    CustomTargetingKey carModelKey = new CustomTargetingKey();
    carModelKey.setDisplayName("car model");
    carModelKey.setName("c" + new Random().nextInt(1000));
    carModelKey.setType(CustomTargetingKeyType.FREEFORM);

    // Create the custom targeting keys on the server.
    CustomTargetingKey[] customTargetingKeys = customTargetingService.createCustomTargetingKeys(
        new CustomTargetingKey[] {genderKey, genreKey, carModelKey});

    for (CustomTargetingKey createdCustomTargetingKey : customTargetingKeys) {
      System.out.printf("A custom targeting key with ID \"%d\", name \"%s\", and display name "
          + "\"%s\" was created.\n", createdCustomTargetingKey.getId(),
          createdCustomTargetingKey.getName(), createdCustomTargetingKey.getDisplayName());
    }

    // Set the created custom targeting keys.
    genderKey = customTargetingKeys[0];
    genreKey = customTargetingKeys[1];
    carModelKey = customTargetingKeys[2];

    // Create custom targeting value for the predefined gender key.
    CustomTargetingValue genderMaleValue = new CustomTargetingValue();
    genderMaleValue.setCustomTargetingKeyId(genderKey.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(genderKey.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(genreKey.getId());
    genreComedyValue.setDisplayName("comedy");
    genreComedyValue.setName("comedy");
    genreComedyValue.setMatchType(CustomTargetingValueMatchType.EXACT);

    CustomTargetingValue genreDramaValue = new CustomTargetingValue();
    genreDramaValue.setCustomTargetingKeyId(genreKey.getId());
    genreDramaValue.setDisplayName("drama");
    genreDramaValue.setName("drama");
    genreDramaValue.setMatchType(CustomTargetingValueMatchType.EXACT);

    // Create custom targeting value for the free-form car model key. These are
    // values that would be suggested in the UI or can be used when targeting
    // with a FreeFormCustomCriteria.
    CustomTargetingValue carModelHondaValue = new CustomTargetingValue();
    carModelHondaValue.setCustomTargetingKeyId(carModelKey.getId());
    carModelHondaValue.setDisplayName("~honda");
    carModelHondaValue.setName("honda");
    // A match type of broad will match anything including "honda",
    // i.e. "~honda".
    carModelHondaValue.setMatchType(CustomTargetingValueMatchType.BROAD);

    // Create the custom targeting values on the server.
    CustomTargetingValue[] customTargetingValues =
        customTargetingService.createCustomTargetingValues(new CustomTargetingValue[] {
            genderMaleValue, genderFemaleValue, genreComedyValue, genreDramaValue,
            carModelHondaValue});

    for (CustomTargetingValue createdCustomTargetingValue : customTargetingValues) {
      System.out.printf("A custom targeting value with ID \"%d\", belonging to key with ID \"%d\", "
View Full Code Here

      int totalResultSetSize = 0;
      statementBuilder.offset(0);

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

        if (page.getResults() != null) {
          totalResultSetSize = page.getTotalResultSetSize();
          for (CustomTargetingValue customTargetingValue : page.getResults()) {
            System.out.printf("%d) Custom targeting value with ID \"%d\", belonging to key "
                + "with ID \"%d\", name \"%s\" and display name \"%s\" was found.\n",
                totalResultsCounter++,
                customTargetingValue.getId(),
                customTargetingValue.getCustomTargetingKeyId(),
View Full Code Here

        .withBindVariableValue(
            "contentBrowseCustomTargetingKeyId", contentBrowseCustomTargetingKeyId)
        .withBindVariableValue("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();

    // Create a statement to select all content.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
View Full Code Here

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

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

      // Perform action.
      UpdateResult result = licaService.performLineItemCreativeAssociationAction(
          action, statementBuilder.toStatement());
View Full Code Here

    CustomFieldValue numberCustomFieldValue = new CustomFieldValue();
    numberCustomFieldValue.setCustomFieldId(numberCustomFieldId);
    numberCustomFieldValue.setValue(numberValue);

    // Create drop-down custom field value.
    DropDownCustomFieldValue dropDownCustomFieldValue = new DropDownCustomFieldValue();
    dropDownCustomFieldValue.setCustomFieldId(dropDownCustomFieldId);
    dropDownCustomFieldValue.setCustomFieldOptionId(customFieldOptionId);

    // Create a combined custom field value list of existing different custom
    // field values and new ones.
    List<BaseCustomFieldValue> combinedCustomFieldValues = Lists.newArrayList();
    if (lineItem.getCustomFieldValues() != null) {
View Full Code Here

    // Get the LabelService.
    LabelServiceInterface labelService =
        dfpServices.get(session, LabelServiceInterface.class);

    // Get the label.
    Label label = labelService.getLabel(labelId);

    // Update the label description.
    label.setDescription("New label description");

    // Update the label on the server.
    Label[] labels =
        labelService.updateLabels(new Label[] {label});
View Full Code Here

    // Get the LabelService.
    LabelServiceInterface labelService =
        dfpServices.get(session, LabelServiceInterface.class);

    // Create a competitive exclusion label.
    Label competitiveExclusionLabel = new Label();
    competitiveExclusionLabel.setName(
        "Car company label #" + new Random().nextInt(Integer.MAX_VALUE));
    competitiveExclusionLabel.setTypes(new LabelType[] {LabelType.COMPETITIVE_EXCLUSION});

    // Create an ad unit frequency cap label.
    Label adUnitFrequencyCapLabel = new Label();
    adUnitFrequencyCapLabel.setName(
        "Don't run too often label #" + new Random().nextInt(Integer.MAX_VALUE));
    adUnitFrequencyCapLabel.setTypes(new LabelType[] {LabelType.AD_UNIT_FREQUENCY_CAP});

    // Create the labels on the server.
    Label[] labels =
        labelService.createLabels(new Label[] {competitiveExclusionLabel, adUnitFrequencyCapLabel});
View Full Code Here

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

    do {
      // Get labels by statement.
      LabelPage page =
          labelService.getLabelsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (Label label : page.getResults()) {
          System.out.printf(
              "%d) Label with ID \"%d\" and name \"%s\" was found.\n", i++,
              label.getId(), label.getName());
        }
      }
View Full Code Here

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

    do {
      // Get labels by statement.
      LabelPage page =
          labelService.getLabelsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (Label label : page.getResults()) {
          System.out.printf("%d) Label with ID \"%d\" will be deactivated.\n", i++, label.getId());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.axis.v201306.BooleanValue

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.