query method

Query your data with filters and parameters that you define.

Returns zero or more rows grouped by the row keys that you define. You must define a date range of one or more days. When date is one of the group by values, any days without data are omitted from the result list. If you need to know which days have data, issue a broad date range query grouped by date for any metric, and see which day rows are returned.

request - The metadata request object.

Request parameters:

siteUrl - The site's URL, including protocol. For example: http://www.example.com/.

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

Completes with a SearchAnalyticsQueryResponse.

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<SearchAnalyticsQueryResponse> query(
  SearchAnalyticsQueryRequest request,
  core.String siteUrl, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'webmasters/v3/sites/' +
      commons.escapeVariable('$siteUrl') +
      '/searchAnalytics/query';

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