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

Examples of com.google.api.ads.dfp.axis.v201302.CustomFieldServiceInterface


    // Create inventory targeting.
    InventoryTargeting inventoryTargeting = new InventoryTargeting();

    // Create ad unit targeting for the root ad unit.
    AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
    adUnitTargeting.setAdUnitId(rootAdUnitId);
    adUnitTargeting.setIncludeDescendants(true);

    inventoryTargeting.setTargetedAdUnits(new AdUnitTargeting[] {adUnitTargeting});

    // Create targeting.
    Targeting targeting = new Targeting();
View Full Code Here


      return (Value) value;
    } else if (value == null) {
      return new TextValue();
    } else {
      if (value instanceof Boolean) {
        BooleanValue booleanValue = new BooleanValue();
        booleanValue.setValue((Boolean) value);
        return booleanValue;
      } else if (value instanceof Double || value instanceof Long || value instanceof Integer) {
        NumberValue numberValue = new NumberValue();
        numberValue.setValue(value.toString());
        return numberValue;
View Full Code Here

    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);

    // Create the creative placeholder.
    CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
    creativePlaceholder.setSize(size);

    // Set the size of creatives that can be associated with this line item.
    lineItem.setCreativePlaceholders(new CreativePlaceholder[] {creativePlaceholder});

    // Set the length of the line item to run.
View Full Code Here

  private static final String CUSTOM_FIELD_ID = "INSERT_CUSTOM_FIELD_ID_HERE";

  public static void runExample(DfpServices dfpServices, DfpSession session, long customFieldId)
      throws Exception {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService =
        dfpServices.get(session, CustomFieldServiceInterface.class);

    // Create a statement to select a custom field.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("WHERE id = :id")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("id", customFieldId);

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

    do {
      // Get custom fields by statement.
      CustomFieldPage page =
          customFieldService.getCustomFieldsByStatement(statementBuilder.toStatement());

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

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

    System.out.printf("Number of custom fields to be deactivated: %d\n", totalResultSetSize);

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

      // Create action.
      com.google.api.ads.dfp.axis.v201302.DeactivateCustomFields action =
          new com.google.api.ads.dfp.axis.v201302.DeactivateCustomFields();

      // Perform action.
      UpdateResult result = customFieldService.performCustomFieldAction(
          action, statementBuilder.toStatement());

      if (result != null && result.getNumChanges() > 0) {
        System.out.printf("Number of custom fields deactivated: %d\n", result.getNumChanges());
      } else {
View Full Code Here

  public static void runExample(DfpServices dfpServices, DfpSession session,
      long numberCustomFieldId, long customFieldOptionId, long lineItemId)
      throws Exception {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService =
        dfpServices.get(session, CustomFieldServiceInterface.class);

    // Get the LineItemService.
    LineItemServiceInterface lineItemService =
        dfpServices.get(session, LineItemServiceInterface.class);

    // Get the drop-down custom field ID.
    long dropDownCustomFieldId =
        customFieldService.getCustomFieldOption(customFieldOptionId).getCustomFieldId();

    // Get the line item.
    LineItem lineItem = lineItemService.getLineItem(lineItemId);

    // Create number custom field value.
View Full Code Here

*/
public class GetCustomFieldsForLineItems {

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService =
        dfpServices.get(session, CustomFieldServiceInterface.class);

    // Create a statement to only select custom fields for line items.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("entityType = :entityType")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("entityType", CustomFieldEntityType.LINE_ITEM.toString());

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

    do {
      // Get custom fields by statement.
      CustomFieldPage page =
          customFieldService.getCustomFieldsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (CustomField customField : page.getResults()) {
View Full Code Here

  private static final String CUSTOM_FIELD_ID = "INSERT_CUSTOM_FIELD_ID_HERE";

  public static void runExample(DfpServices dfpServices, DfpSession session, long customFieldId)
      throws Exception {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService =
        dfpServices.get(session, CustomFieldServiceInterface.class);

    // Get the custom field.
    CustomField customField = customFieldService.getCustomField(customFieldId);

    // Update the custom field description.
    customField.setDescription("New custom field description");

    // Update the custom field on the server.
    CustomField[] customFields =
        customFieldService.updateCustomFields(new CustomField[] {customField});

    for (CustomField updatedCustomField : customFields) {
      System.out.printf(
          "Custom field with ID \"%d\" and name \"%s\" was updated.\n",
          updatedCustomField.getId(), updatedCustomField.getName());
View Full Code Here

*/
public class GetAllCustomFields {

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService =
        dfpServices.get(session, CustomFieldServiceInterface.class);

    // Create a statement to get all custom fields.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

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

    do {
      // Get custom fields by statement.
      CustomFieldPage page =
          customFieldService.getCustomFieldsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (CustomField customField : page.getResults()) {
View Full Code Here

*/
public class CreateCustomFieldsAndOptions {

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService =
        dfpServices.get(session, CustomFieldServiceInterface.class);

    // Create a number custom field that can be used for an external ID in the
    // API.
    CustomField numberCustomField = new CustomField();
    numberCustomField.setName("External ID #" + new Random().nextInt(Integer.MAX_VALUE));
    numberCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
    numberCustomField.setDataType(CustomFieldDataType.NUMBER);
    numberCustomField.setVisibility(CustomFieldVisibility.API_ONLY);

    // Create a drop-down custom field that can be used in the UI.
    CustomField dropDownCustomField = new CustomField();
    dropDownCustomField.setName(
        "Internal approval status #" + new Random().nextInt(Integer.MAX_VALUE));
    dropDownCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
    dropDownCustomField.setDataType(CustomFieldDataType.DROP_DOWN);
    dropDownCustomField.setVisibility(CustomFieldVisibility.FULL);

    // Create the custom fields on the server.
    CustomField[] customFields = customFieldService.createCustomFields(
        new CustomField[] {numberCustomField, dropDownCustomField});

    for (CustomField createdCustomField : customFields) {
      System.out.printf("A custom field with ID \"%d\" and name \"%s\" was created.\n",
          createdCustomField.getId(), createdCustomField.getName());
    }

    // Set the created drop-down custom field.
    dropDownCustomField = customFields[1];

    // Create approved custom field option.
    CustomFieldOption approvedCustomFieldOption = new CustomFieldOption();
    approvedCustomFieldOption.setDisplayName("APPROVED");
    approvedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());

    // Create unapproved custom field option.
    CustomFieldOption unapprovedCustomFieldOption = new CustomFieldOption();
    unapprovedCustomFieldOption.setDisplayName("UNAPPROVED");
    unapprovedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());

    // Create the custom field options on the server.
    CustomFieldOption[] customFieldOptions = customFieldService.createCustomFieldOptions(
        new CustomFieldOption[] {approvedCustomFieldOption, unapprovedCustomFieldOption});

    for (CustomFieldOption createdCustomFieldOption : customFieldOptions) {
      System.out.printf(
          "A custom field option with ID \"%d\" and display name \"%s\" was created.\n",
View Full Code Here

      } else if (value instanceof String) {
        TextValue textValue = new TextValue();
        textValue.setValue((String) value);
        return textValue;
      } else if (value instanceof DateTime) {
        DateTimeValue dateTimeValue = new DateTimeValue();
        dateTimeValue.setValue((DateTime) value);
        return dateTimeValue;
      } else {
        throw new IllegalArgumentException("Unsupported Value type [" + value.getClass() + "]");
      }
    }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.axis.v201302.CustomFieldServiceInterface

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.