Package com.google.api.ads.dfp.lib.utils.v201306

Examples of com.google.api.ads.dfp.lib.utils.v201306.DateUtils


    System.out.println("Running report job.");

    // Run report job.
    long reportJobId = reportService.runReportJob(reportJob).getId();

    final ReportUtils reportUtils = new ReportUtils(reportService, reportJobId);

    // Change to your file location.
    final String gzCsvPath = "/path/to/filename.csv.gz";

    // Change to use synchronous or asynchronous downloading.
    boolean useSynchronous = true;

    if (useSynchronous) {
      // Download gzipped CSV synchronously.
      try {
        System.out.println("Waiting for report to finish.");
        if (reportUtils.waitForReportReady()) {
          System.out.print("Downloading report to " + gzCsvPath + "...");
          reportUtils.downloadReport(ExportFormat.CSV_DUMP, gzCsvPath);
          System.out.println("done.");
        } else {
          System.out.println("The report failed to schedule.");
        }
      } catch (IOException e) {
        System.out.println("Report did not download for reason: " + e.getMessage());
        e.printStackTrace();
      }
    } else {
      // Download gzipped CSV asynchronously.
      Thread reportThread = reportUtils.whenReportReady(new ReportCallback() {
        public void onSuccess() {
          try {
            System.out.print("Downloading report to " + gzCsvPath + "...");
            reportUtils.downloadReport(ExportFormat.CSV_DUMP, gzCsvPath);
            System.out.println("done.");
          } catch (IOException e) {
            System.out.println("Report did not download for reason: " + e.getMessage());
            e.printStackTrace();
          }
View Full Code Here


    System.out.println("Running report job.");

    // Run report job.
    long reportJobId = reportService.runReportJob(reportJob).getId();

    final ReportUtils reportUtils = new ReportUtils(reportService, reportJobId);

    // Change to use synchronous or asynchronous downloading.
    boolean useSynchronous = true;

    if (useSynchronous) {
      // Get CSV synchronously.
      try {
        System.out.println("Waiting for report to finish.");
        if (reportUtils.waitForReportReady()) {
          System.out.println("Retrieving CSV...");
          String csvString = reportUtils.getReport(ExportFormat.CSV_DUMP);

          // Get CSV as list of string arrays.
          List<String[]> csv = CsvUtils.getCsvDataArray(new StringReader(csvString), true);

          // Output the csv.
          System.out.println(csvString);
        } else {
          System.out.println("The report failed to schedule.");
        }
      } catch (IOException e) {
        System.out.println("Report did not download for reason: " + e.getMessage());
        e.printStackTrace();
      }
    } else {
      // Get XML asynchronously.
      Thread reportThread = reportUtils.whenReportReady(new ReportCallback() {
        public void onSuccess() {
          try {
            System.out.println("Retrieving CSV...");
            String csvString = reportUtils.getReport(ExportFormat.CSV_DUMP);

            // Get CSV as list of string arrays.
            List<String[]> csv = CsvUtils.getCsvDataArray(new StringReader(csvString), true);

            // Output the csv.
View Full Code Here

      LabelServiceInterface labelService = user.getService(DfpService.V201306.LABEL_SERVICE);

      // Create statement text to select active labels.
      String statementText = "WHERE isActive = :isActive LIMIT 500";
      Statement filterStatement =
          new StatementBuilder("").putValue("isActive", true).toStatement();

      // Set defaults for page and offset.
      LabelPage page = new LabelPage();
      int offset = 0;
      List<Long> labelIds = new ArrayList<Long>();
View Full Code Here

      Long userId = Long.parseLong("INSERT_USER_ID_HERE");

      // Create filter text to select user team associations by the user ID.
      String statementText = "WHERE userId = :userId LIMIT 500";
      Statement filterStatement =
        new StatementBuilder("")
            .putValue("userId", userId)
            .toStatement();

      // Get user team associations by statement.
      UserTeamAssociationPage page =
View Full Code Here

      CreativeTemplateServiceInterface creativeTemplateService =
          user.getService(DfpService.V201306.CREATIVE_TEMPLATE_SERVICE);

      // Create a statement to only select system defined creative templates.
      Statement filterStatement =
          new StatementBuilder("WHERE type = :creativeTemplateType LIMIT 500").putValue(
              "creativeTemplateType", CreativeTemplateType.SYSTEM_DEFINED.toString()).toStatement();

      // Get creative templates by statement.
      CreativeTemplatePage page =
          creativeTemplateService.getCreativeTemplatesByStatement(filterStatement);
View Full Code Here

      long currentUserId = userService.getCurrentUser().getId();

      // Create filter text to select user team associations by the user ID.
      String statementText = "WHERE userId = :userId LIMIT 500";
      Statement filterStatement =
        new StatementBuilder("")
            .putValue("userId", currentUserId)
            .toStatement();

      // Get user team associations by statement.
      UserTeamAssociationPage page =
View Full Code Here

      // Get the LabelService.
      LabelServiceInterface labelService = user.getService(DfpService.V201306.LABEL_SERVICE);

      // Create statement text to select active labels.
      Statement filterStatement = new StatementBuilder("WHERE isActive = :isActive LIMIT 500")
          .putValue("isActive", true).toStatement();

      // Get the labels by statement.
      LabelPage page =
          labelService.getLabelsByStatement(filterStatement);
View Full Code Here

      // Get the LabelService.
      LabelServiceInterface labelService = user.getService(DfpService.V201306.LABEL_SERVICE);

      // Create a statement to select labels ordered by name.
      Statement filterStatement =
          new StatementBuilder("ORDER BY name LIMIT 500").toStatement();

      // Get labels by statement.
      LabelPage page = labelService.getLabelsByStatement(filterStatement);

      if (page.getResults() != null) {
View Full Code Here

      ContactServiceInterface contactService =
          user.getService(DfpService.V201306.CONTACT_SERVICE);

      // Create a statement to only select contacts that aren't invited yet.
      Statement filterStatement =
          new StatementBuilder("WHERE status = :status LIMIT 500")
              .putValue("status", ContactStatus.UNINVITED.toString()).toStatement();

      // Get contacts by statement.
      ContactPage page = contactService.getContactsByStatement(filterStatement);
View Full Code Here

      Long userId = Long.parseLong("INSERT_USER_ID_HERE");

      // Create filter text to select user team associations by the user ID.
      String statementText = "WHERE userId = :userId LIMIT 500";
      Statement filterStatement =
        new StatementBuilder("")
            .putValue("userId", userId)
            .toStatement();

      // Set defaults for page and offset.
      UserTeamAssociationPage page = new UserTeamAssociationPage();
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.lib.utils.v201306.DateUtils

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.