@dmgt/google-ad-manager-api
Version:
Typed Google Ad Manager API
54 lines (53 loc) • 2.04 kB
TypeScript
import { IncomingMessage } from 'node:http';
import { GoogleAdManager, ReportService } from '..';
export interface RunAndDownloadReportOpts {
exportFormat: ReportService.GetReportDownloadUrl['exportFormat'];
statusCheckInterval?: number;
query: ReportService.ReportQuery;
}
/**
* @returns An incoming stream of a GZIP'd result
* @example
* ```
* runAndDownloadReport(api, {
* exportFormat: 'CSV_DUMP',
* query: {
* dimensions: [
* 'DATE',
* 'COUNTRY_NAME',
* 'DEVICE_CATEGORY_NAME',
* 'AD_UNIT_ID',
* 'AD_UNIT_NAME',
* ],
* columns: [
* 'AD_UNIT_CODE',
* 'TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS',
* 'TOTAL_ACTIVE_VIEW_MEASURABLE_IMPRESSIONS',
* 'AD_SERVER_ACTIVE_VIEW_VIEWABLE_IMPRESSIONS',
* 'TOTAL_LINE_ITEM_LEVEL_ALL_REVENUE',
* ],
* startDate: { year: '2024', month: '4', day: '30' },
* endDate: { year: '2024', month: '4', day: '30' },
* dateRangeType: 'TODAY',
* adUnitView: 'HIERARCHICAL',
* },
* }).then(response => {
* response.pipe(
* createWriteStream('result.csv.gz', {
* autoClose: true,
* }))
* )
* })
* ```
*/
export declare function runAndDownloadReport(api: GoogleAdManager, { exportFormat, query, statusCheckInterval, }: RunAndDownloadReportOpts): Promise<IncomingMessage>;
/**
* GAM's report api will fail unless the order is:
* 1. dimensions
* 2. [adUnitView]
* ...
*/
export declare function ensureCorrectOrderOfReportQueryParameters(query: ReportService.ReportQuery): ReportService.ReportQuery;
export declare function runReport(client: ReportService.ReportServiceClient, query: ReportService.ReportQuery): Promise<number>;
export declare function waitForReportToFinish(client: ReportService.ReportServiceClient, jobId: number, statusCheckInterval: number): Promise<void>;
export declare function streamReportResult(client: ReportService.ReportServiceClient, jobId: number, exportFormat: RunAndDownloadReportOpts['exportFormat']): Promise<IncomingMessage>;