get method

Future<RealtimeData> get(
  1. String ids,
  2. String metrics, {
  3. String? dimensions,
  4. String? filters,
  5. int? maxResults,
  6. String? sort,
  7. String? $fields,
})

Returns real time data for a view (profile).

Request parameters:

ids - Unique table ID for retrieving real time data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID. Value must have pattern ga:\[0-9\]+.

metrics - A comma-separated list of real time metrics. E.g., 'rt:activeUsers'. At least one metric must be specified. Value must have pattern (ga:.+)|(rt:.+).

dimensions - A comma-separated list of real time dimensions. E.g., 'rt:medium,rt:city'. Value must have pattern (ga:.+)|(rt:.+).

filters - A comma-separated list of dimension or metric filters to be applied to real time data. Value must have pattern (ga:.+)|(rt:.+).

maxResults - The maximum number of entries to include in this feed.

sort - A comma-separated list of dimensions or metrics that determine the sort order for real time data. Value must have pattern (-)?((ga:.+)|(rt:.+)).

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

Completes with a RealtimeData.

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<RealtimeData> get(
  core.String ids,
  core.String metrics, {
  core.String? dimensions,
  core.String? filters,
  core.int? maxResults,
  core.String? sort,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    'ids': [ids],
    'metrics': [metrics],
    if (dimensions != null) 'dimensions': [dimensions],
    if (filters != null) 'filters': [filters],
    if (maxResults != null) 'max-results': ['${maxResults}'],
    if (sort != null) 'sort': [sort],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'data/realtime';

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