generate method
Generate an AdSense report based on the report request sent in the query parameters.
Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
Request parameters:
startDate
- Start of the date range to report on in "YYYY-MM-DD" format,
inclusive.
Value must have pattern
\d{4}-\d{2}-\d{2}|(today|startOfMonth|startOfYear)((\[\-\+\]\d+\[dwmy\]){0,3}?)
.
endDate
- End of the date range to report on in "YYYY-MM-DD" format,
inclusive.
Value must have pattern
\d{4}-\d{2}-\d{2}|(today|startOfMonth|startOfYear)((\[\-\+\]\d+\[dwmy\]){0,3}?)
.
dimension
- Dimensions to base the report on.
Value must have pattern \[a-zA-Z_\]+
.
filter
- Filters to be run on the report.
Value must have pattern \[a-zA-Z_\]+(==|=@).+
.
locale
- Optional locale to use for translating report output to a local
language. Defaults to "en_US" if not specified.
Value must have pattern \[a-zA-Z_\]+
.
maxResults
- The maximum number of rows of report data to return.
Value must be between "0" and "50000".
metric
- Numeric columns to include in the report.
Value must have pattern \[a-zA-Z_\]+
.
sort
- The name of a dimension or metric to sort the resulting report
on, optionally prefixed with "+" to sort ascending or "-" to sort
descending. If no prefix is specified, the column is sorted ascending.
Value must have pattern (\+|-)?\[a-zA-Z_\]+
.
startIndex
- Index of the first row of report data to return.
Value must be between "0" and "5000".
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Report.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client
completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<Report> generate(
core.String startDate,
core.String endDate, {
core.List<core.String>? dimension,
core.List<core.String>? filter,
core.String? locale,
core.int? maxResults,
core.List<core.String>? metric,
core.List<core.String>? sort,
core.int? startIndex,
core.String? $fields,
}) async {
final queryParams_ = <core.String, core.List<core.String>>{
'startDate': [startDate],
'endDate': [endDate],
if (dimension != null) 'dimension': dimension,
if (filter != null) 'filter': filter,
if (locale != null) 'locale': [locale],
if (maxResults != null) 'maxResults': ['${maxResults}'],
if (metric != null) 'metric': metric,
if (sort != null) 'sort': sort,
if (startIndex != null) 'startIndex': ['${startIndex}'],
if ($fields != null) 'fields': [$fields],
};
const url_ = 'reports';
final response_ = await _requester.request(
url_,
'GET',
queryParams: queryParams_,
);
return Report.fromJson(response_ as core.Map<core.String, core.dynamic>);
}