Package com.google.api.ads.dfp.v201311

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


      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the LineItemCreativeAssociationService.
      LineItemCreativeAssociationServiceInterface licaService =
          user.getService(DfpService.V201311.LINEITEMCREATIVEASSOCIATION_SERVICE);

      // Set the line item ID and creative set ID to associate.
      Long lineItemId = Long.parseLong("INSERT_LINE_ITEM_ID_HERE");
      Long creativeSetId = Long.parseLong("INSERT_CREATIVE_SET_ID_HERE");

      LineItemCreativeAssociation lica = new LineItemCreativeAssociation();
      lica.setCreativeSetId(creativeSetId);
      lica.setLineItemId(lineItemId);

      // Create the LICAs on the server.
      lica = licaService.createLineItemCreativeAssociations(
          new LineItemCreativeAssociation[] {lica})[0];

      System.out.println("A LICA with line item ID \"" + lica.getLineItemId()
          + "\" and creative set ID \"" + lica.getCreativeSetId() + "\" was created.");
    } catch (Exception e) {
View Full Code Here


          "WHERE deliveryRateType = :deliveryRateType AND orderId = :orderId LIMIT 500")
              .putValue("orderId", orderId)
              .putValue("deliveryRateType", DeliveryRateType.EVENLY.toString()).toStatement();

      // Get line items by statement.
      LineItemPage page = lineItemService.getLineItemsByStatement(filterStatement);

      if (page.getResults() != null) {
        LineItem[] lineItems = page.getResults();

        // Update each local line item object by changing its delivery rate.
        for (int i = 0; i < lineItems.length; i++) {
          // Archived line items cannot be updated.
          if (lineItems[i].getIsArchived()) {
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the LineItemService.
      LineItemServiceInterface lineItemService =
          user.getService(DfpService.V201311.LINEITEM_SERVICE);

      // Set the order that all created line items will belong to and the
      // placement ID to target.
      Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");
      long[] targetedPlacementIds = new long[] {Long.parseLong("INSERT_PLACEMENT_ID_HERE")};

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

      // Create geographical targeting.
      GeoTargeting geoTargeting = new GeoTargeting();

      // Include the US, Quebec, Canada, and the B3P Canada postal code.
      Location countryLocation = new Location();
      countryLocation.setId(2840L);

      Location regionLocation = new Location();
      regionLocation.setId(20123L);

      Location postalCodeLocation = new Location();
      postalCodeLocation.setId(9000093L);

      geoTargeting.setTargetedLocations(new Location[] {countryLocation, regionLocation,
          postalCodeLocation});

      // Exclude Chicago and the New York metro area.
      Location cityLocation = new Location();
      cityLocation.setId(1016367L);

      Location metroLocation = new Location();
      metroLocation.setId(200501L);
      geoTargeting.setExcludedLocations(new Location[] {cityLocation, metroLocation});

      // Exclude domains that are not under the network's control.
      UserDomainTargeting userDomainTargeting = new UserDomainTargeting();
      userDomainTargeting.setDomains(new String[] {"usa.gov"});
      userDomainTargeting.setTargeted(false);

      // Create day-part targeting.
      DayPartTargeting dayPartTargeting = new DayPartTargeting();
      dayPartTargeting.setTimeZone(DeliveryTimeZone.BROWSER);

      // Target only the weekend in the browser's timezone.
      DayPart saturdayDayPart = new DayPart();
      saturdayDayPart.setDayOfWeek(DayOfWeek.SATURDAY);
      saturdayDayPart.setStartTime(new TimeOfDay(0, MinuteOfHour.ZERO));
      saturdayDayPart.setEndTime(new TimeOfDay(24, MinuteOfHour.ZERO));

      DayPart sundayDayPart = new DayPart();
      sundayDayPart.setDayOfWeek(DayOfWeek.SUNDAY);
      sundayDayPart.setStartTime(new TimeOfDay(0, MinuteOfHour.ZERO));
      sundayDayPart.setEndTime(new TimeOfDay(24, MinuteOfHour.ZERO));
      dayPartTargeting.setDayParts(new DayPart[] {saturdayDayPart, sundayDayPart});

      // Create technology targeting.
      TechnologyTargeting technologyTargeting = new TechnologyTargeting();

      // Create browser targeting.
      BrowserTargeting browserTargeting = new BrowserTargeting();
      browserTargeting.setIsTargeted(true);

      // Target just the Chrome browser.
      Technology browserTechnology = new Technology();
      browserTechnology.setId(500072L);
      browserTargeting.setBrowsers(new Technology[] {browserTechnology});
      technologyTargeting.setBrowserTargeting(browserTargeting);

      // Create targeting.
      Targeting targeting = new Targeting();
      targeting.setGeoTargeting(geoTargeting);
      targeting.setInventoryTargeting(inventoryTargeting);
      targeting.setUserDomainTargeting(userDomainTargeting);
      targeting.setDayPartTargeting(dayPartTargeting);
      targeting.setTechnologyTargeting(technologyTargeting);

      // 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 \""
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the LineItemService.
      LineItemServiceInterface lineItemService =
          user.getService(DfpService.V201311.LINEITEM_SERVICE);

      // Set the ID of the order to get line items from.
      Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

      // Create a statement to get line items with even delivery rates.
      Statement filterStatement = new StatementBuilder(
          "WHERE deliveryRateType = :deliveryRateType AND orderId = :orderId LIMIT 500")
              .putValue("orderId", orderId)
              .putValue("deliveryRateType", DeliveryRateType.EVENLY.toString()).toStatement();

      // Get line items by statement.
      LineItemPage page = lineItemService.getLineItemsByStatement(filterStatement);

      if (page.getResults() != null) {
        LineItem[] lineItems = page.getResults();

        // Update each local line item object by changing its delivery rate.
        for (int i = 0; i < lineItems.length; i++) {
          // Archived line items cannot be updated.
          if (lineItems[i].getIsArchived()) {
            lineItems[i] = null;
          } else {
            lineItems[i].setDeliveryRateType(DeliveryRateType.AS_FAST_AS_POSSIBLE);
          }
        }

        // Update the line items on the server.
        lineItems = lineItemService.updateLineItems(lineItems);

        if (lineItems != null) {
          for (LineItem lineItem : lineItems) {
            System.out.println("A line item with ID \""
                + lineItem.getId() + "\", belonging to order ID \""
View Full Code Here

      // Create geographical targeting.
      GeoTargeting geoTargeting = new GeoTargeting();

      // Include the US, Quebec, Canada, and the B3P Canada postal code.
      Location countryLocation = new Location();
      countryLocation.setId(2840L);

      Location regionLocation = new Location();
      regionLocation.setId(20123L);

      Location postalCodeLocation = new Location();
      postalCodeLocation.setId(9000093L);

      geoTargeting.setTargetedLocations(new Location[] {countryLocation, regionLocation,
          postalCodeLocation});

      // Exclude Chicago and the New York metro area.
      Location cityLocation = new Location();
      cityLocation.setId(1016367L);

      Location metroLocation = new Location();
      metroLocation.setId(200501L);
      geoTargeting.setExcludedLocations(new Location[] {cityLocation, metroLocation});

      // Exclude domains that are not under the network's control.
      UserDomainTargeting userDomainTargeting = new UserDomainTargeting();
      userDomainTargeting.setDomains(new String[] {"usa.gov"});
View Full Code Here

        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);
View Full Code Here

      // Create an array to store local order objects.
      Order[] orders = new Order[5];

      for (int i = 0; i < 5; i++) {
        Order order = new Order();
        order.setName("Order #" + i);
        order.setAdvertiserId(advertiserId);
        order.setSalespersonId(salespersonId);
        order.setTraffickerId(traffickerId);

        orders[i] = order;
      }

      // Create the orders on the server.
      orders = orderService.createOrders(orders);

      if (orders != null) {
        for (Order order : orders) {
          System.out.println("An order with ID \""
              + order.getId() + "\" and named \"" + order.getName() + "\" was created.");
        }
      } else {
        System.out.println("No orders created.");
      }
    } catch (Exception e) {
View Full Code Here

      // Set the ID of the order to get.
      Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

      // Get the order.
      Order order = orderService.getOrder(orderId);

      if (order != null) {
        System.out.println("An order with ID \""
            + order.getId() + "\", name \"" + order.getName()
            + "\", and advertiser ID \"" + order.getAdvertiserId()
            + "\" was found.");
      } else {
        System.out.println("No order found for this ID.");
      }
    } catch (Exception e) {
View Full Code Here

    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.
View Full Code Here

        // 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.
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201311.Order

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.