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

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


*/
public class GetAllAudienceSegments {

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the AudienceSegmentService.
    AudienceSegmentServiceInterface audienceSegmentService =
        dfpServices.get(session, AudienceSegmentServiceInterface.class);

    // Create a statement to select all audience segments.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

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

    do {
      // Get audience segments by statement.
      AudienceSegmentPage page =
          audienceSegmentService.getAudienceSegmentsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (AudienceSegment audienceSegment : page.getResults()) {
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

*/
public class GetSystemDefinedCreativeTemplates {

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the CreativeTemplateService.
    CreativeTemplateServiceInterface creativeTemplateService =
        dfpServices.get(session, CreativeTemplateServiceInterface.class);

    // Create a statement to select only system defined creative templates.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("type = :type")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("type", CreativeTemplateType.SYSTEM_DEFINED.toString());

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

    do {
      // Get creative templates by statement.
      CreativeTemplatePage page =
          creativeTemplateService.getCreativeTemplatesByStatement(statementBuilder.toStatement());

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

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

    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

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

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

    long matched = forecast.getMatchedUnits();
    double availablePercent = (forecast.getAvailableUnits() / (matched * 1.0)) * 100;
    String unitType = forecast.getUnitType().toString().toLowerCase();

    System.out.printf("%d %s matched.\n", matched, unitType);
    System.out.printf("%.2f%% %s available.\n", availablePercent, unitType);

    if (forecast.getPossibleUnits() != null) {
      double possiblePercent = (forecast.getPossibleUnits() / (matched * 1.0)) * 100;
      System.out.printf("%.2f%% %s possible.\n", possiblePercent, unitType);
    }
  }
View Full Code Here

    // Get the ForecastService.
    ForecastServiceInterface forecastService =
        dfpServices.get(session, ForecastServiceInterface.class);

    // Get forecast for line item.
    Forecast forecast = forecastService.getForecastById(lineItemId);

    long matched = forecast.getMatchedUnits();
    double availablePercent = (forecast.getAvailableUnits() / (matched * 1.0)) * 100;
    String unitType = forecast.getUnitType().toString().toLowerCase();

    System.out.printf("%d %s matched.\n", matched, unitType);
    System.out.printf("%.2f%% %s available.\n", availablePercent, unitType);

    if (forecast.getPossibleUnits() != null) {
      double possiblePercent = (forecast.getPossibleUnits() / (matched * 1.0)) * 100;
      System.out.printf("%.2f%% %s possible.\n", possiblePercent, unitType);
    }
  }
View Full Code Here

public class GetForecast {

  public static void runExample(DfpServices dfpServices, DfpSession session)
      throws Exception {
    // Get the ForecastService.
    ForecastServiceInterface forecastService =
        dfpServices.get(session, ForecastServiceInterface.class);

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

    // Get the root ad unit ID used to target the whole site.
    String rootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();

    // 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();
    targeting.setInventoryTargeting(inventoryTargeting);

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

    // Set the roadblocking type.
    lineItem.setRoadblockingType(RoadblockingType.ONE_OR_MORE);

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

    // Create creative placeholder size.
    Size size = new Size();
    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.
    lineItem.setStartDateTimeType(StartDateTimeType.IMMEDIATELY);
    lineItem.setEndDateTime(
        DateTimes.toDateTime(Instant.now().plus(Duration.standardDays(30L)), "America/New_York"));

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

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

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

    long matched = forecast.getMatchedUnits();
    double availablePercent = (forecast.getAvailableUnits() / (matched * 1.0)) * 100;
    String unitType = forecast.getUnitType().toString().toLowerCase();

View Full Code Here

TOP

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

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.