// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the ReportService.
ReportServiceInterface reportService = user.getService(DfpService.V201306.REPORT_SERVICE);
// Create report job.
ReportJob reportJob = new ReportJob();
// Create report query.
ReportQuery reportQuery = new ReportQuery();
reportQuery.setDateRangeType(DateRangeType.CUSTOM_DATE);
reportQuery.setStartDate(DateUtils.fromString("2011-03-01"));
reportQuery.setEndDate(DateUtils.today("PST"));
reportQuery.setDimensions(new Dimension[] {
Dimension.ORDER_ID, Dimension.ORDER_NAME, Dimension.LINE_ITEM_ID,
Dimension.LINE_ITEM_NAME});
reportQuery.setColumns(new Column[] {Column.AD_SERVER_IMPRESSIONS,
Column.AD_SERVER_CLICKS, Column.AD_SERVER_CTR,
Column.AD_SERVER_CPM_AND_CPC_REVENUE, Column.AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM});
reportJob.setReportQuery(reportQuery);
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";