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

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


*/
public class GetFirstPartyAudienceSegments {

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

    // Create a statement to only select first party audience segments.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("type = :type")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("type", "FIRST_PARTY");

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


  private static final String AUDIENCE_SEGMENT_ID = "INSERT_AUDIENCE_SEGMENT_ID_HERE";

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

    // Create a statement to only select a specified first party audience
    // segment.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("WHERE id = :audienceSegmentId and type = :type")
        .orderBy("id ASC")
        .limit(1)
        .withBindVariableValue("audienceSegmentId", audienceSegmentId)
        .withBindVariableValue("type", "FIRST_PARTY");

    // Get the audience segment.
    RuleBasedFirstPartyAudienceSegment audienceSegment =
        (RuleBasedFirstPartyAudienceSegment) audienceSegmentService
            .getAudienceSegmentsByStatement(statementBuilder.toStatement()).getResults()[0];

    // Update the member expiration days.
    audienceSegment.setMembershipExpirationDays(180);

    // Update the audience segment on the server.
    AudienceSegment[] audienceSegments = audienceSegmentService.updateAudienceSegments(
        new FirstPartyAudienceSegment[] {audienceSegment});

    for (AudienceSegment updatedAudienceSegment : audienceSegments) {
      System.out.printf(
          "Audience segment with ID \"%d\" and name \"%s\" was updated.\n",
View Full Code Here

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

      // Get the AudienceSegmentService.
      AudienceSegmentServiceInterface audienceSegmentService =
          user.getService(DfpService.V201208.AUDIENCE_SEGMENT_SERVICE);

      // Set defaults for page and filterStatement.
      AudienceSegmentPage page;
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all audience segments.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get audience segments by statement.
        page = audienceSegmentService.getAudienceSegmentsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (AudienceSegment audienceSegment : page.getResults()) {
            System.out.println(i + ") Audience segment with ID \"" + audienceSegment.getId()
View Full Code Here

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

      // Get the AudienceSegmentService.
      AudienceSegmentServiceInterface audienceSegmentService =
          user.getService(DfpService.V201211.AUDIENCE_SEGMENT_SERVICE);

      // Set defaults for page and filterStatement.
      AudienceSegmentPage page;
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all audience segments.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get audience segments by statement.
        page = audienceSegmentService.getAudienceSegmentsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (AudienceSegment audienceSegment : page.getResults()) {
            System.out.println(i + ") Audience segment with ID \"" + audienceSegment.getId()
View Full Code Here

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

      // Get the AudienceSegmentService.
      AudienceSegmentServiceInterface audienceSegmentService =
          user.getService(DfpService.V201302.AUDIENCE_SEGMENT_SERVICE);

      // Set defaults for page and filterStatement.
      AudienceSegmentPage page;
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all audience segments.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get audience segments by statement.
        page = audienceSegmentService.getAudienceSegmentsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (AudienceSegment audienceSegment : page.getResults()) {
            System.out.println(i + ") Audience segment with ID \"" + audienceSegment.getId()
View Full Code Here

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

      // Get the AudienceSegmentService.
      AudienceSegmentServiceInterface audienceSegmentService =
          user.getService(DfpService.V201306.AUDIENCE_SEGMENT_SERVICE);

      // Set defaults for page and filterStatement.
      AudienceSegmentPage page;
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all audience segments.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get audience segments by statement.
        page = audienceSegmentService.getAudienceSegmentsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (AudienceSegment audienceSegment : page.getResults()) {
            System.out.println(i + ") Audience segment with ID \"" + audienceSegment.getId()
View Full Code Here

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

      // Get the AudienceSegmentService.
      AudienceSegmentServiceInterface audienceSegmentService =
          user.getService(DfpService.V201308.AUDIENCE_SEGMENT_SERVICE);

      // Set defaults for page and filterStatement.
      AudienceSegmentPage page;
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all audience segments.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get audience segments by statement.
        page = audienceSegmentService.getAudienceSegmentsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (AudienceSegment audienceSegment : page.getResults()) {
            System.out.println(i + ") Audience segment with ID \"" + audienceSegment.getId()
View Full Code Here

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

      // Get the AudienceSegmentService.
      AudienceSegmentServiceInterface audienceSegmentService =
          user.getService(DfpService.V201311.AUDIENCE_SEGMENT_SERVICE);

      // Set defaults for page and filterStatement.
      AudienceSegmentPage page;
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all audience segments.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get audience segments by statement.
        page = audienceSegmentService.getAudienceSegmentsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (AudienceSegment audienceSegment : page.getResults()) {
            System.out.println(i + ") Audience segment with ID \"" + audienceSegment.getId()
View Full Code Here

      // Set the ID of the company to get.
      Long companyId = Long.parseLong("INSERT_COMPANY_ID_HERE");

      // Get the company.
      Company company = companyService.getCompany(companyId);

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

      // Create an array to store local company objects.
      Company[] companies = new Company[5];

      for (int i = 0; i < 5; i++) {
        Company company = new Company();
        company.setName("Advertiser #" + i);
        company.setType(CompanyType.ADVERTISER);
        companies[i] = company;
      }

      // Create the companies on the server.
      companies = companyService.createCompanies(companies);

      if (companies != null) {
        for (Company company : companies) {
          System.out.println("A company with ID \"" + company.getId()
              + "\", name \"" + company.getName()
              + "\", and type \"" + company.getType() + "\" was created.");
        }
      } else {
        System.out.println("No companies created.");
      }
    } catch (Exception e) {
View Full Code Here

TOP

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

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.