Examples of ReportDownloadResponse


Examples of com.google.api.ads.adwords.lib.utils.ReportDownloadResponse

    try {
      // Set the property api.adwords.reportDownloadTimeout or call
      // ReportDownloader.setReportDownloadTimeout to set a timeout (in milliseconds)
      // for CONNECT and READ in report downloads.
      ReportDownloadResponse response =
          new ReportDownloader(session).downloadReport(query, DownloadFormat.CSV);
      FileOutputStream fos = new FileOutputStream(new File(reportFile));
      Streams.copy(response.getInputStream(), fos);
      fos.close();
      System.out.println("Report successfully downloaded: " + reportFile);
    } catch (ReportDownloadResponseException e) {
      System.out.println("Report was not downloaded. " + e);
    }
View Full Code Here

Examples of com.google.api.ads.adwords.lib.utils.ReportDownloadResponse

    try {
      // Set the property api.adwords.reportDownloadTimeout or call
      // ReportDownloader.setReportDownloadTimeout to set a timeout (in milliseconds)
      // for CONNECT and READ in report downloads.
      ReportDownloadResponse response =
          new ReportDownloader(session).downloadReport(reportDefinition);
      FileOutputStream fos = new FileOutputStream(new File(reportFile));
      Streams.copy(response.getInputStream(), fos);
      fos.close();
      System.out.println("Report successfully downloaded: " + reportFile);
    } catch (ReportDownloadResponseException e) {
      System.out.println("Report was not downloaded. " + e);
    }
View Full Code Here

Examples of com.google.api.ads.adwords.lib.utils.ReportDownloadResponse

  @Test
  public void testSuccess() throws Exception {
    ByteArrayInputStream stream = new ByteArrayInputStream("Report data".getBytes());
    RawReportDownloadResponse rawResponse = new RawReportDownloadResponse(200, stream);
    ReportDownloadResponse response =
        new ReportDownloader(adWordsSession).handleResponse(rawResponse);
    assertEquals(200, response.getHttpStatus());
    assertEquals(stream, response.getInputStream());
    assertEquals("SUCCESS", response.getHttpResponseMessage());
  }
View Full Code Here

Examples of com.google.api.ads.adwords.lib.utils.ReportDownloadResponse

  @Test
  public void testSuccess() throws Exception {
    ByteArrayInputStream stream = new ByteArrayInputStream("Report data".getBytes());
    RawReportDownloadResponse rawResponse = new RawReportDownloadResponse(200, stream);
    ReportDownloadResponse response =
        new ReportDownloader(adWordsSession).handleResponse(rawResponse);
    assertEquals(200, response.getHttpStatus());
    assertEquals(stream, response.getInputStream());
    assertEquals("SUCCESS", response.getHttpResponseMessage());
  }
View Full Code Here

Examples of com.google.api.ads.adwords.lib.utils.ReportDownloadResponse

    reportDefinition.setDownloadFormat(DownloadFormat.CSV);
    // Enable to allow rows with zero impressions to show.
    reportDefinition.setIncludeZeroImpressions(true);
    reportDefinition.setSelector(reportSelector);

    ReportDownloadResponse response =
        new ReportDownloader(session).downloadReport(reportDefinition);
    if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) {
      FileOutputStream fos = new FileOutputStream(new File(reportFile));
      Streams.copy(response.getInputStream(), fos);
      fos.close();
      System.out.println("Report successfully downloaded: " + reportFile);
    } else {
      System.out.println("Report was not downloaded. " + response.getHttpStatus() + ": "
          + response.getHttpResponseMessage());
    }
  }
View Full Code Here

Examples of com.google.api.ads.adwords.lib.utils.ReportDownloadResponse

      throws ValidationException, ReportException, ReportDownloadResponseException {

    InputStream inputStream = null;

    ReportDownloader reportDownloader = new ReportDownloader(adWordsSession);
    ReportDownloadResponse reportDownloadResponse =
        reportDownloader.downloadReport(this.reportDefinition);

    if (reportDownloadResponse.getHttpStatus() == HttpURLConnection.HTTP_OK) {
      inputStream = reportDownloadResponse.getInputStream();

    } else {
      System.out.println("getHttpStatus():" + reportDownloadResponse.getHttpStatus());
      System.out.println(
          "getHttpResponseMessage():" + reportDownloadResponse.getHttpResponseMessage());
    }
    return inputStream;
  }
View Full Code Here

Examples of com.google.api.ads.adwords.lib.utils.ReportDownloadResponse

      FileNotFoundException {

    File reportFile = null;

    ReportDownloader reportDownloader = new ReportDownloader(adWordsSession);
    ReportDownloadResponse reportDownloadResponse =
        reportDownloader.downloadReport(this.reportDefinition);

    if (reportDownloadResponse.getHttpStatus() == HttpURLConnection.HTTP_OK) {
      File tempFile = this.createTempFile(this.cid, this.reportDefinition.getReportType().value());
      BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(tempFile));
      copy(reportDownloadResponse.getInputStream(), output);
      output.close();
      reportFile = tempFile;

    } else {
      System.out.println("getHttpStatus():" + reportDownloadResponse.getHttpStatus());
      System.out.println(
          "getHttpResponseMessage():" + reportDownloadResponse.getHttpResponseMessage());
    }
    return reportFile;
  }
View Full Code Here

Examples of com.google.api.adwords.lib.utils.v201306.ReportDownloadResponse

      String query =
          "SELECT AdGroupId, Id, KeywordText, KeywordMatchType, Impressions, Clicks, Cost "
          + "FROM KEYWORDS_PERFORMANCE_REPORT WHERE Impressions > 0 DURING YESTERDAY";

      FileOutputStream fos = new FileOutputStream(new File(reportFile));
      ReportDownloadResponse response =
          ReportUtils.downloadReport(user, query, DownloadFormat.CSV, fos);
      if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) {
        System.out.println("Report successfully downloaded: " + reportFile);
      } else {
        System.out.println("Report was not downloaded. " + response.getHttpStatus() + ": "
            + response.getHttpResponseMessage());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of com.google.api.adwords.lib.utils.v201306.ReportDownloadResponse

      reportDefinition.setDownloadFormat(DownloadFormat.CSV);
      reportDefinition.setIncludeZeroImpressions(false);
      reportDefinition.setSelector(selector);

      FileOutputStream fos = new FileOutputStream(new File(reportFile));
      ReportDownloadResponse response = ReportUtils.downloadReport(user, reportDefinition, fos);
      if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) {
        System.out.println("Report successfully downloaded: " + reportFile);
      } else {
        System.out.println("Report was not downloaded. " + response.getHttpStatus() + ": "
            + response.getHttpResponseMessage());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of com.google.api.adwords.lib.utils.v201309.ReportDownloadResponse

      String query =
          "SELECT AdGroupId, Id, KeywordText, KeywordMatchType, Impressions, Clicks, Cost "
          + "FROM KEYWORDS_PERFORMANCE_REPORT WHERE Impressions > 0 DURING YESTERDAY";

      FileOutputStream fos = new FileOutputStream(new File(reportFile));
      ReportDownloadResponse response =
          ReportUtils.downloadReport(user, query, DownloadFormat.CSV, fos);
      if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) {
        System.out.println("Report successfully downloaded: " + reportFile);
      } else {
        System.out.println("Report was not downloaded. " + response.getHttpStatus() + ": "
            + response.getHttpResponseMessage());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
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.