Java Code Examples for com.google.api.ads.adwords.lib.utils.ReportDownloadResponse#getInputStream()

The following examples show how to use com.google.api.ads.adwords.lib.utils.ReportDownloadResponse#getInputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CallableAwqlReportDownloader.java    From adwords-alerting with Apache License 2.0 6 votes vote down vote up
/**
 * Downloads report from API (with retry logic) and transforms the result into a
 * {@link ReportData} object.
 */
@Override
public ReportData call() throws AlertProcessingException {
  ReportDownloaderInterface reportDownloader =
      AdWordsServicesUtil.getUtility(session, ReportDownloaderInterface.class);

  ReportDownloadResponse reportDownloadResponse = null;
  try {
    reportDownloadResponse =
        reportDownloader.downloadReport(reportQuery.generateAWQL(), DownloadFormat.GZIPPED_CSV);
  } catch (ReportException | ReportDownloadResponseException e) {
    String msg = "Failed to download report account " + session.getClientCustomerId() + ".";
    LOGGER.error(msg, e);
    throw new AlertProcessingException(msg, e);
  }
  
  InputStream inputStream = reportDownloadResponse.getInputStream();
  return handleReportStreamResult(inputStream);
}
 
Example 2
Source File: StreamingRunnableProcessor.java    From aw-reporting with Apache License 2.0 6 votes vote down vote up
/**
 * Downloads the file from the API into an InputStream.
 *
 * @return the InputStream from the online report, null if httpStatus is not {@code HTTP_OK}.
 */
private InputStream getReportInputStream() {
  ReportDownloaderInterface reportDownloader =
      AdWordsServicesUtil.getUtility(session, ReportDownloaderInterface.class);
  
  InputStream result = null;
  try {
    ReportDownloadResponse reportDownloadResponse =
        reportDownloader.downloadReport(reportDefinition);
    result = reportDownloadResponse.getInputStream();
  } catch (ReportException | ReportDownloadResponseException e) {
    logger.error(
        "Failed to download report stream for {} with account {}.",
        reportDefinition.getReportType(),
        session.getClientCustomerId(),
        e);
  }

  return result;
}
 
Example 3
Source File: CallableReportDownloader.java    From aw-reporting with Apache License 2.0 5 votes vote down vote up
/**
 * Downloads report from API (with retry logic) and returns a {@link File} object.
 */
@Override
public File call() throws ReportProcessingException {
  ReportDownloadResponse reportDownloadResponse = getReportDownloadResponse();

  InputStream inputStream = reportDownloadResponse.getInputStream();
  return handleReportStreamResult(inputStream);
}