generateCsv method

Future<HttpBody> generateCsv(
  1. String account, {
  2. String? currencyCode,
  3. String? dateRange,
  4. List<String>? dimensions,
  5. int? endDate_day,
  6. int? endDate_month,
  7. int? endDate_year,
  8. List<String>? filters,
  9. String? languageCode,
  10. int? limit,
  11. List<String>? metrics,
  12. List<String>? orderBy,
  13. String? reportingTimeZone,
  14. int? startDate_day,
  15. int? startDate_month,
  16. int? startDate_year,
  17. String? $fields,
})

Generates a csv formatted ad hoc report.

Request parameters:

account - Required. The account which owns the collection of reports. Format: accounts/{account} Value must have pattern ^accounts/\[^/\]+$.

currencyCode - The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.

dateRange - Date range of the report, if unset the range will be considered CUSTOM. Possible string values are:

  • "REPORTING_DATE_RANGE_UNSPECIFIED" : Unspecified date range.
  • "CUSTOM" : A custom date range specified using the start_date and end_date fields. This is the default if no ReportingDateRange is provided.
  • "TODAY" : Current day.
  • "YESTERDAY" : Yesterday.
  • "MONTH_TO_DATE" : From the start of the current month to the current day. e.g. if the current date is 2020-03-12 then the range will be [2020-03-01, 2020-03-12].
  • "YEAR_TO_DATE" : From the start of the current year to the current day. e.g. if the current date is 2020-03-12 then the range will be [2020-01-01, 2020-03-12].
  • "LAST_7_DAYS" : Last 7 days, excluding current day.
  • "LAST_30_DAYS" : Last 30 days, excluding current day.

dimensions - Dimensions to base the report on.

endDate_day - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.

endDate_month - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.

endDate_year - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.

filters - A list of [filters](/adsense/management/reporting/filtering) to apply to the report. All provided filters must match in order for the data to be included in the report.

languageCode - The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).

limit - The maximum number of rows of report data to return. Reports producing more rows than the requested limit will be truncated. If unset, this defaults to 100,000 rows for Reports.GenerateReport and 1,000,000 rows for Reports.GenerateCsvReport, which are also the maximum values permitted here. Report truncation can be identified (for Reports.GenerateReport only) by comparing the number of rows returned to the value returned in total_matched_rows.

metrics - Required. Reporting metrics.

orderBy - The name of a dimension or metric to sort the resulting report on, can be prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.

reportingTimeZone - Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see changing the time zone of your reports. Possible string values are:

  • "REPORTING_TIME_ZONE_UNSPECIFIED" : Unspecified timezone.
  • "ACCOUNT_TIME_ZONE" : Use the account timezone in the report.
  • "GOOGLE_TIME_ZONE" : Use the Google timezone in the report (America/Los_Angeles).

startDate_day - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.

startDate_month - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.

startDate_year - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.

$fields - Selector specifying which fields to include in a partial response.

Completes with a HttpBody.

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<HttpBody> generateCsv(
  core.String account, {
  core.String? currencyCode,
  core.String? dateRange,
  core.List<core.String>? dimensions,
  core.int? endDate_day,
  core.int? endDate_month,
  core.int? endDate_year,
  core.List<core.String>? filters,
  core.String? languageCode,
  core.int? limit,
  core.List<core.String>? metrics,
  core.List<core.String>? orderBy,
  core.String? reportingTimeZone,
  core.int? startDate_day,
  core.int? startDate_month,
  core.int? startDate_year,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (currencyCode != null) 'currencyCode': [currencyCode],
    if (dateRange != null) 'dateRange': [dateRange],
    if (dimensions != null) 'dimensions': dimensions,
    if (endDate_day != null) 'endDate.day': ['${endDate_day}'],
    if (endDate_month != null) 'endDate.month': ['${endDate_month}'],
    if (endDate_year != null) 'endDate.year': ['${endDate_year}'],
    if (filters != null) 'filters': filters,
    if (languageCode != null) 'languageCode': [languageCode],
    if (limit != null) 'limit': ['${limit}'],
    if (metrics != null) 'metrics': metrics,
    if (orderBy != null) 'orderBy': orderBy,
    if (reportingTimeZone != null) 'reportingTimeZone': [reportingTimeZone],
    if (startDate_day != null) 'startDate.day': ['${startDate_day}'],
    if (startDate_month != null) 'startDate.month': ['${startDate_month}'],
    if (startDate_year != null) 'startDate.year': ['${startDate_year}'],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ =
      'v2/' + core.Uri.encodeFull('$account') + '/reports:generateCsv';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return HttpBody.fromJson(response_ as core.Map<core.String, core.dynamic>);
}