Examples of LineItem


Examples of com.google.api.ads.dfp.v201306.LineItem

      Targeting targeting = new Targeting();
      targeting.setInventoryTargeting(inventoryTargeting);
      targeting.setTechnologyTargeting(technologyTargeting);

      // Create local line item object.
      LineItem lineItem = new LineItem();
      lineItem.setName("Mobile line item");
      lineItem.setOrderId(orderId);
      lineItem.setTargeting(targeting);
      lineItem.setLineItemType(LineItemType.STANDARD);
      lineItem.setAllowOverbook(true);

      // Set the target platform to mobile.
      lineItem.setTargetPlatform(TargetPlatform.MOBILE);

      // Set the creative rotation type to even.
      lineItem.setCreativeRotationType(CreativeRotationType.EVEN);

      // Create the creative placeholder.
      CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
      creativePlaceholder.setSize(new Size(300, 250, false));

      // 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.
      lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
      lineItem.setEndDateTime(DateTimeUtils.fromString("2012-09-01T00:00:00"));

      // Set the cost per unit to $2.
      lineItem.setCostType(CostType.CPM);
      lineItem.setCostPerUnit(new Money("USD", 2000000L));

      // Set the number of units bought to 500,000 so that the budget is
      // $1,000.
      lineItem.setUnitsBought(500000L);
      lineItem.setUnitType(UnitType.IMPRESSIONS);

      // Create the line item on the server.
      lineItem = lineItemService.createLineItem(lineItem);

      if (lineItem != null) {
        System.out.println("A line item with ID \"" + lineItem.getId()
            + "\", belonging to order ID \"" + lineItem.getOrderId() + "\", and named \""
            + lineItem.getName() + "\" was created.");
      } else {
        System.out.println("No line item created.");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

Examples of com.google.api.ads.dfp.v201306.LineItem

    // Set the end date time to have the line line item run till.
    String endDateTime = "INSERT_END_DATE_TIME_HERE";

    // Create prospective line item.
    LineItem lineItem = new LineItem();
    lineItem.setLineItemType(LineItemType.SPONSORSHIP);
    lineItem.setTargeting(targeting);

    // Create the creative placeholder.
    CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
    creativePlaceholder.setSize(new Size(300, 250, false));

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

    // Set the line item's time to be now until the projected end date time.
    lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
    lineItem.setEndDateTime(DateTimeUtils.fromString(endDateTime));

    // Set the line item to use 50% of the impressions.
    lineItem.setUnitType(UnitType.IMPRESSIONS);
    lineItem.setUnitsBought(50L);

    // Set the cost type to match the unit type.
    lineItem.setCostType(CostType.CPM);

    // Get forecast for line item.
    Forecast forecast = forecastService.getForecast(lineItem);

    // Display results.
View Full Code Here

Examples of com.google.api.ads.dfp.v201308.LineItem

      // Get the drop-down custom field.
      DropDownCustomField dropDownCustomField =
          (DropDownCustomField) customFieldService.getCustomField(dropDownCustomFieldId);

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

      // Create custom field values.
      List<BaseCustomFieldValue> customFieldValues = new ArrayList<BaseCustomFieldValue>();
      TextValue textValue = new TextValue();
      textValue.setValue("Custom field value");

      CustomFieldValue customFieldValue = new CustomFieldValue();
      customFieldValue.setCustomFieldId(customFieldId);
      customFieldValue.setValue(textValue);
      customFieldValues.add(customFieldValue);

      DropDownCustomFieldValue dropDownCustomFieldValue = new DropDownCustomFieldValue();
      dropDownCustomFieldValue.setCustomFieldId(dropDownCustomFieldId);
      dropDownCustomFieldValue.setCustomFieldOptionId(customFieldOptionId);
      customFieldValues.add(dropDownCustomFieldValue);

      // Only add existing custom field values for different custom fields than
      // the ones you are setting.
      if (lineItem.getCustomFieldValues() != null) {
        for (BaseCustomFieldValue oldCustomFieldValue : lineItem.getCustomFieldValues()) {
          if (!oldCustomFieldValue.getCustomFieldId().equals(customFieldId)
              && !oldCustomFieldValue.getCustomFieldId().equals(dropDownCustomFieldId)) {
            customFieldValues.add(oldCustomFieldValue);
          }
        }
      }

      lineItem.setCustomFieldValues(customFieldValues.toArray(new BaseCustomFieldValue[]{}));

      // Update the line item on the server.
      LineItem[] lineItems = lineItemService.updateLineItems(new LineItem[] {lineItem});

      if (lineItems != null) {
        for (LineItem updatedLineItem : lineItems) {
          List<String> customFieldValueStrings = new ArrayList<String>();
          for (BaseCustomFieldValue baseCustomFieldValue : lineItem.getCustomFieldValues()) {
            if (baseCustomFieldValue instanceof CustomFieldValue
                && ((CustomFieldValue) baseCustomFieldValue).getValue() instanceof TextValue) {
              customFieldValueStrings.add("{ID: '" + baseCustomFieldValue.getCustomFieldId()
                  + "', value: '"
                  + ((TextValue) ((CustomFieldValue) baseCustomFieldValue).getValue()).getValue()
                  + "'}");
            } else if (baseCustomFieldValue instanceof DropDownCustomFieldValue) {
              customFieldValueStrings.add("{ID: '" + baseCustomFieldValue.getCustomFieldId()
                  + "', custom field option ID: '"
                  + ((DropDownCustomFieldValue) baseCustomFieldValue).getCustomFieldOptionId()
                  + "'}");
            }
          }
          System.out.println("A line item with ID \"" + lineItem.getId()
              + "\" set with custom field values \""
              + StringUtils.join(customFieldValueStrings, ","));
        }
      } else {
        System.out.println("No line items were updated.");
View Full Code Here

Examples of com.google.api.ads.dfp.v201308.LineItem

      // Create an array to store local line item objects.
      LineItem[] lineItems = new LineItem[5];

      for (int i = 0; i < 5; i++) {
        LineItem lineItem = new LineItem();
        lineItem.setName("Line item #" + i);
        lineItem.setOrderId(orderId);
        lineItem.setTargeting(targeting);
        lineItem.setLineItemType(LineItemType.STANDARD);
        lineItem.setAllowOverbook(true);

        // Set the creative rotation type to even.
        lineItem.setCreativeRotationType(CreativeRotationType.EVEN);

        // Create the creative placeholder.
        CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
        creativePlaceholder.setSize(new Size(300, 250, false));

        // 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.
        lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
        lineItem.setEndDateTime(DateTimeUtils.fromString("2012-09-01T00:00:00"));

        // Set the cost per unit to $2.
        lineItem.setCostType(CostType.CPM);
        lineItem.setCostPerUnit(new Money("USD", 2000000L));

        // Set the number of units bought to 500,000 so that the budget is
        // $1,000.
        lineItem.setUnitsBought(500000L);
        lineItem.setUnitType(UnitType.IMPRESSIONS);

        lineItems[i] = lineItem;
      }

      // Create the line items on the server.
      lineItems = lineItemService.createLineItems(lineItems);

      if (lineItems != null) {
        for (LineItem lineItem : lineItems) {
          System.out.println("A line item with ID \"" + lineItem.getId()
              + "\", belonging to order ID \"" + lineItem.getOrderId() + "\", and named \""
              + lineItem.getName() + "\" was created.");
        }
      } else {
        System.out.println("No line items created.");
      }
    } catch (Exception e) {
View Full Code Here

Examples of com.google.api.ads.dfp.v201308.LineItem

    // Set the end date time to have the line line item run till.
    String endDateTime = "INSERT_END_DATE_TIME_HERE";

    // Create prospective line item.
    LineItem lineItem = new LineItem();
    lineItem.setLineItemType(LineItemType.SPONSORSHIP);
    lineItem.setTargeting(targeting);

    // Create the creative placeholder.
    CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
    creativePlaceholder.setSize(new Size(300, 250, false));

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

    // Set the line item's time to be now until the projected end date time.
    lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
    lineItem.setEndDateTime(DateTimeUtils.fromString(endDateTime));

    // Set the line item to use 50% of the impressions.
    lineItem.setUnitType(UnitType.IMPRESSIONS);
    lineItem.setUnitsBought(50L);

    // Set the cost type to match the unit type.
    lineItem.setCostType(CostType.CPM);

    // Get forecast for line item.
    Forecast forecast = forecastService.getForecast(lineItem);

    // Display results.
View Full Code Here

Examples of com.google.api.ads.dfp.v201308.LineItem

          new CustomCriteriaNode[] {customCriteria2, customCriteria3});
      topCustomCriteriaSet.setChildren(
          new CustomCriteriaNode[] {customCriteria1, subCustomCriteriaSet});

      // Set the custom criteria targeting on the line item.
      LineItem lineItem = lineItemService.getLineItem(lineItemId);
      lineItem.getTargeting().setCustomTargeting(topCustomCriteriaSet);

      // Update the line items on the server.
      lineItem = lineItemService.updateLineItem(lineItem);

      // Display the updated line item.
      System.out.printf("Line item with ID %s update with custom criteria targeting \n%s\n",
          lineItem.getId(),
          getCustomCriteriaSetString(lineItem.getTargeting().getCustomTargeting(), 0));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of com.google.api.ads.dfp.v201308.LineItem

      Targeting targeting = new Targeting();
      targeting.setInventoryTargeting(inventoryTargeting);
      targeting.setTechnologyTargeting(technologyTargeting);

      // Create local line item object.
      LineItem lineItem = new LineItem();
      lineItem.setName("Mobile line item");
      lineItem.setOrderId(orderId);
      lineItem.setTargeting(targeting);
      lineItem.setLineItemType(LineItemType.STANDARD);
      lineItem.setAllowOverbook(true);

      // Set the target platform to mobile.
      lineItem.setTargetPlatform(TargetPlatform.MOBILE);

      // Set the creative rotation type to even.
      lineItem.setCreativeRotationType(CreativeRotationType.EVEN);

      // Create the creative placeholder.
      CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
      creativePlaceholder.setSize(new Size(300, 250, false));

      // 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.
      lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
      lineItem.setEndDateTime(DateTimeUtils.fromString("2012-09-01T00:00:00"));

      // Set the cost per unit to $2.
      lineItem.setCostType(CostType.CPM);
      lineItem.setCostPerUnit(new Money("USD", 2000000L));

      // Set the number of units bought to 500,000 so that the budget is
      // $1,000.
      lineItem.setUnitsBought(500000L);
      lineItem.setUnitType(UnitType.IMPRESSIONS);

      // Create the line item on the server.
      lineItem = lineItemService.createLineItem(lineItem);

      if (lineItem != null) {
        System.out.println("A line item with ID \"" + lineItem.getId()
            + "\", belonging to order ID \"" + lineItem.getOrderId() + "\", and named \""
            + lineItem.getName() + "\" was created.");
      } else {
        System.out.println("No line item created.");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

Examples of com.google.api.ads.dfp.v201308.LineItem

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

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

      if (lineItem != null) {
        System.out.println("Line item with ID \""
                + lineItem.getId() + "\", belonging to order ID \""
                + lineItem.getOrderId() + "\", and named \"" + lineItem.getName()
                + "\" was found.");
      } else {
        System.out.println("No line item found for this ID.");
      }
    } catch (Exception e) {
View Full Code Here

Examples of com.google.api.ads.dfp.v201308.LineItem

      targeting.setCustomTargeting(customCriteriaSet);
      targeting.setInventoryTargeting(inventoryTargeting);
      targeting.setVideoPositionTargeting(videoPositionTargeting);

      // Create local line item object.
      LineItem lineItem = new LineItem();
      lineItem.setName("Video line item");
      lineItem.setOrderId(orderId);
      lineItem.setTargeting(targeting);
      lineItem.setLineItemType(LineItemType.SPONSORSHIP);
      lineItem.setAllowOverbook(true);

      // Set the environment type to video.
      lineItem.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);

      // Set the creative rotation type to optimized.
      lineItem.setCreativeRotationType(CreativeRotationType.OPTIMIZED);

      // Create the master creative placeholder.
      CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
      creativeMasterPlaceholder.setSize(new Size(400, 300, false));

      // Create companion creative placeholders.
      CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder();
      companionCreativePlaceholder1.setSize(new Size(300, 250, false));

      CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder();
      companionCreativePlaceholder2.setSize(new Size(728, 90, false));

      // Set companion creative placeholders.
      creativeMasterPlaceholder.setCompanions(new CreativePlaceholder[] {
          companionCreativePlaceholder1, companionCreativePlaceholder2});

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

      // Set delivery of video companions to optional.
      lineItem.setCompanionDeliveryOption(CompanionDeliveryOption.OPTIONAL);

      // Set the length of the line item to run.
      lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
      lineItem.setEndDateTime(DateTimeUtils.fromString("2013-09-01T00:00:00"));

      // Set the cost per day to $1.
      lineItem.setCostType(CostType.CPD);
      lineItem.setCostPerUnit(new Money("USD", 1000000L));

      // Set the percentage to be 100%.
      lineItem.setUnitsBought(100L);

      // Create the line item on the server.
      lineItem = lineItemService.createLineItem(lineItem);

      if (lineItem != null) {
        System.out.println("A line item with ID \"" + lineItem.getId()
            + "\", belonging to order ID \"" + lineItem.getOrderId() + "\", and named \""
            + lineItem.getName() + "\" was created.");
      } else {
        System.out.println("No line item created.");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

Examples of com.google.api.ads.dfp.v201311.LineItem

      // Create an array to store local line item objects.
      LineItem[] lineItems = new LineItem[5];

      for (int i = 0; i < 5; i++) {
        LineItem lineItem = new LineItem();
        lineItem.setName("Line item #" + i);
        lineItem.setOrderId(orderId);
        lineItem.setTargeting(targeting);
        lineItem.setLineItemType(LineItemType.STANDARD);
        lineItem.setAllowOverbook(true);

        // Set the creative rotation type to even.
        lineItem.setCreativeRotationType(CreativeRotationType.EVEN);

        // Create the creative placeholder.
        CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
        creativePlaceholder.setSize(new Size(300, 250, false));

        // 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.
        lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
        lineItem.setEndDateTime(DateTimeUtils.fromString("2012-09-01T00:00:00"));

        // Set the cost per unit to $2.
        lineItem.setCostType(CostType.CPM);
        lineItem.setCostPerUnit(new Money("USD", 2000000L));

        // Set the number of units bought to 500,000 so that the budget is
        // $1,000.
        lineItem.setUnitsBought(500000L);
        lineItem.setUnitType(UnitType.IMPRESSIONS);

        lineItems[i] = lineItem;
      }

      // Create the line items on the server.
      lineItems = lineItemService.createLineItems(lineItems);

      if (lineItems != null) {
        for (LineItem lineItem : lineItems) {
          System.out.println("A line item with ID \"" + lineItem.getId()
              + "\", belonging to order ID \"" + lineItem.getOrderId() + "\", and named \""
              + lineItem.getName() + "\" was created.");
        }
      } else {
        System.out.println("No line items created.");
      }
    } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.